User:Dušan Kreheľ/Signpost draft:My idea about wikipage parser

The Signpost



Signpost draft:My idea about wikipage parser

My idea about wikipage parser

This article is about how I got into bot editing and and why it discourages me. This article will deal with the wikipedia page parser.

I started learning the Croatian language. I also decided to use Wikipedia for learning. I checked the Croatian wiki pages dealing with Slovakia. I noticed that the town statistics are 4 years old. I, as well as the programmer, decided to change this state on my own. So I wrote a bot and used the software Wikimate to work through the wiki API. When working on the plwiki, it was already happening somewhere that when the data in the infobox was changed, the definition of the reference remained orphaned in the references. So I created a code that will check and update the state of the reference and its definition after updating the data on the page. But mine didn't do it quite correctly. In addition, the code was strongly focused on writing to work with references and act. statistical data. So I decided to write a new code that will be better written. It will already be in OPP, so that the entire grammar of the wiki page can be implemented later. In the beginning, only necessary things for my bot purpose were implemented (i.e. references, template; but no longer headings, tables). After two new main versions, when testing the syntax-semantics of the Wikimedia wiki page, I decided to stop all work on the code and not to continue development on that code. And also not to continue developing completely new functions that the bot could possibly do. One thing led me to stop the development - very complex or incorrect processing of error syntax entries of the wiki page (obtained by testing MediaWiki). Even if the grammar of the wiki page is defined (it exists, but I can't find the link somehow), there is no RFC document that would specify the entire syntax and semantics of the wiki page, and especially how to deal with bad inputs.

So, I think that if we want to work with bots today in a high-quality and honest manner, it is not possible with 100% certainty now, as it is missed:

  • §1 RFC for the complete syntax-sematic definition of a wiki page,
  • §2 new reference implementation of the parser.

These two paragraphs are more detailed::

  • RFC language definition
    • To define in detail the syntax and semantics, as it is necessary to know (because to exist a right and wrong combinations) where each element ends and begins when creating a document tree, and it is important when creating a subtree of individual node elements.
    • Wikipage page language is actually a mix of HTML and wiki syntax – certain boundaries.
    • Will bring the possibility to use the implementation also in other non-Wikimedia Movement software.
    • Complete the process of separating meta data from the wiki page content (or clearly specifying).
    • Expand of Mediawiki syntax in Out Wikimedia Movement.
  • Does an audit of the wikipedia page language and modernize it sensibly.
  • New wiki parser
    • Create a library where wikipage pages are worked with through DOM.
    • Possibly a freer license (e.g. MIT).
    • Should only work with wiki text.
    • Pair or unpaired HTML characters should be recognized by the wiki parser but not interpreted (maybe).
    • Can enable export of Examples to other formats (plain text or GUI widgets) than just HTML.
    • Can also be used in other software:
      • offline apps for document development,
      • format suitable for user notes,
      • use in other editorial systems (Wordpress, Drupal, …).
  • For the community
    • Quality work is required from bot users and we give them full responsibility when starting the bot, but in my opinion, they currently do not have the best (to a reasonable extent) means for this.
    • The software environment around MediaWiki will be only get bigger and bigger, Example new modules or the new elements (Example Wikifunctions, so it's best to do it now and properly. Practically, the wikipage is made for humans, but nowadays bots operate a lot, so it would be good if it were made for both sides and the syntax should be clear.

The current situation even has a negative effect on the movement:

  • Even if you do the syntactic task of the bots, after a while semantic processing is also necessary (practically: under some conditions, do not perform the given operation) and the author doesn't want that. (Look [[[:m:Special:Permalink/23662865#The_problem_change practical]).
  • Publish Technical RfC: new syntax for multi-line list items/talk page comments
    • Instead of a high-quality implementation of the parser using existing tools, here we add other things to the syntax-semantics of the page. The parser should process the input document block by block rather than line by line.
How to correct multiple line comments? (Example)
Input HTML output
:<div>foo<br>
bar</div>
…
:<comment>foo<br>
bar</comment>
  • When I edit a wiki page, the syntax-semantics for colorsyntax in the source code of the page are not completely identical to those used by the WikiMedia parser.

So here we have the one way – Parsoid, and but this solution also has negative sympathies for me:

  • It is a converter between wiki page and HTML, i.e. fulfills only one requirement for Wikimedia.
  • Processing is not in the form of a single tree (but a record list).
  • This is a plus-minus only-MediaWiki solution.
  • Conversion wiki -> HTML -> wiki is not with the same result (This is important for the bot. Adjustments should only be optional, not default.).
  • It is slow.
  • A widely used thing should be optimized – protection of the planet.

Epilogue

edit

I see that there are two needs when designing and implementing a Wikimedia site:

  • convert from/to HTML
  • have a Wikimedia DOM wiki page – for bot needs.

I don't like that there is no officially defined "Wikimedia DOM wiki page" with access as a wiki document and not an HTML document, and I don't like, for example, access to bots, where access and editing of wiki pages happens via regular significantly. By changing to abstract tree, it could be interesting even outside the Wikimedia movement.

I decided to use the older knowledge in another dwiki project, and certainly more interesting speed of converting wiki pages to HTML.

The converting of speed_testing.wiki to HTML
(on my hardware, 2022-12-09)
Real time Program/implementation
0.000333s dwiki
0.000275s dwiki editor
0.016512s Wikimedia parser[notice 1]
1.260279s Parsoid[notice 2]
  1. ^ mediawiki-core-1.39.0, plus the one change: The value print on all decimal places (one edited line: https://github.com/wikimedia/mediawiki/blob/3d65c37ba466d8646ba1b2f03d936a4598df243e/includes/parser/Parser.php#L796)
  2. ^ The time of the function transformFromWt(): https://github.com/wikimedia/parsoid/blob/f44568161ba0fff71486904c02811a4d925e2142/bin/parse.php#L529

This page is a draft for the next issue of the Signpost. Below is some helpful code that will help you write and format a Signpost draft. If it's blank, you can fill out a template by copy-pasting this in and pressing 'publish changes': {{subst:Wikipedia:Wikipedia Signpost/Templates/Story-preload}}


Images and Galleries
Sidebar images

To put an image in your article, use the following template (link):

TKTK
I understand the primacy of pure feeling in creative art.
{{Wikipedia:Wikipedia Signpost/Templates/Filler image-v2
 |size      = 300px
 |fullwidth = no
 |alt       = TKTK
 |caption   = 
 |image     = 
}}

This will create the file on the right. Keep the 300px in most cases. If writing a 'full width' article, change |fullwidth=no to |fullwidth=yes.

Inline images

Placing

{{Wikipedia:Wikipedia Signpost/Templates/Inline image
 |size     = 300px
 |align    = center
 |alt      = TKTK
 |caption  = 
 |image    =
}}

(link) will instead create an inline image like below

TKTK
The significant thing is feeling, as such, quite apart from the environment in which it is called forth.
Galleries

To create a gallery, use the following

<gallery style="float:right;" mode=packed | heights=200px>
|TKTK
|TKTK
</gallery>

Each line inside the tags should be formatted like File:Whatever.jpg|Caption). This creates:

If you want it centered, remove tstyle="float:right;" from the first line.

Quotes
Framed quotes

To insert a framed quote like the one on the right, use this template (link):

{{Wikipedia:Wikipedia Signpost/Templates/Filler quote-v2
 |1         = 
 |author    = 
 |source    = 
 |fullwidth = 
}}

If writing a 'full width' article, change |fullwidth=no to |fullwidth=yes.

Pull quotes

To insert a pull quote like

use this template (link):

{{Wikipedia:Wikipedia Signpost/Templates/Quote
 |1         = 
 |source    = 
}}
Long quotes

To insert a long inline quote like

The goose is on the loose! The geese are on the lease!
— User:Oscar Wilde
— Quotations Notes from the Underpoop

use this template (link):

{{Wikipedia:Wikipedia Signpost/Templates/block quote
 | text   = 
 | by     = 
 | source = 
 | ts     = 
 | oldid  = 
}}
Side frames

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

A caption

Side frames help put content in sidebar vignettes. For instance, this one (link):

{{Wikipedia:Wikipedia Signpost/Templates/Filler frame-v2
 |1         = Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
 |caption   = A caption
 |fullwidth = no
}}

gives the frame on the right. This is useful when you want to insert non-standard images, quotes, graphs, and the like.

Example − Graph/Charts
A caption

For example, to insert the {{Graph:Chart}} generated by

{{Graph:Chart
 |width=250|height=100|type=line
 |x=1,2,3,4,5,6,7,8|y=10,12,6,14,2,10,7,9
}}

in a frame, simple put the graph code in |1=

{{Wikipedia:Wikipedia Signpost/Templates/Filler frame-v2
 |1=
{{Graph:Chart
 |width=250|height=100|type=line
 |x=1,2,3,4,5,6,7,8|y=10,12,6,14,2,10,7,9
}}
 |caption=A caption
 |fullwidth=no
}}

to get the framed Graph:Chart on the right.

If writing a 'full width' article, change |fullwidth=no to |fullwidth=yes.

Two-column vs full width styles

If you keep the 'normal' preloaded draft and work from there, you will be using the two-column style. This is perfectly fine in most cases and you don't need to do anything.

However, every time you have a |fullwidth=no and change it to |fullwidth=yes (or vice-versa), the article will take that style from that point onwards (|fullwidth=yes → full width, |fullwidth=no → two-column). By default, omitting |fullwidth= is the same as putting |fullwidth=no and the article will have two columns after that. Again, this is perfectly fine in most cases, and you don't need to do anything.

However, you can also fine-tune which style is used at which point in an article.

To switch from two-column → full width style midway in an article, insert

{{Wikipedia:Wikipedia Signpost/Templates/Signpost-block-end-v2}}
{{Wikipedia:Wikipedia Signpost/Templates/Signpost-block-start-v2|fullwidth=yes}}

where you want the switch to happen.

To switch from full width → two-column style midway in an article, insert

{{Wikipedia:Wikipedia Signpost/Templates/Signpost-block-end-v2}}
{{Wikipedia:Wikipedia Signpost/Templates/Signpost-block-start-v2|fullwidth=no}}

where you want the switch to happen.

Article series

To add a series of 'related articles' your article, use the following code

Related articles
Visual Editor

Five, ten, and fifteen years ago
1 January 2023

VisualEditor, endowment, science, and news in brief
5 August 2015

HTTPS-only rollout completed, proposal to enable VisualEditor for new accounts
17 June 2015

VisualEditor and MediaWiki updates
29 April 2015

Security issue fixed; VisualEditor changes
4 February 2015


More articles

{{Signpost series
 |type        = sidebar-v2
 |tag         = VisualEditor
 |seriestitle = Visual Editor
 |fullwidth   = no
}}

or

{{Signpost series
 |type        = sidebar-v2
 |tag         = VisualEditor
 |seriestitle = Visual Editor
 |fullwidth   = yes
}}

will create the sidebar on the right. If writing a 'full width' article, change |fullwidth=no to |fullwidth=yes. A partial list of valid |tag= parameters can be found at here and will decide the list of articles presented. |seriestitle= is the title that will appear below 'Related articles' in the box.

Alternatively, you can use

{{Signpost series
 |type        = inline
 |tag         = VisualEditor
 |tag_name    = visual editor
 |tag_pretext = the
}}

at the end of an article to create

For Signpost coverage on the visual editor see the visual editor series.

If you think a topic would make a good series, but you don't see a tag for it, or that all the articles in a series seem 'old', ask for help at the WT:NEWSROOM. Many more tags exist, but they haven't been documented yet.

Links and such

By the way, the template that you're reading right now is {{Editnotices/Group/Wikipedia:Wikipedia Signpost/Next issue}} (edit). A list of the preload templates for Signpost articles can be found here.