Class: MediaWiktory::Wikipedia::Actions::Parse
- Defined in:
- lib/mediawiktory/wikipedia/actions/parse.rb
Overview
Parses content and returns parser output.
Usage:
api.parse.title(value).perform # returns string with raw output
# or
api.parse.title(value).response # returns output parsed and wrapped into Response object
See Base for generic explanation of working with MediaWiki actions and Response for working with action responses.
All action's parameters are documented as its public methods, see below.
Instance Method Summary collapse
-
#contentformat(value) ⇒ self
Content serialization format used for the input text.
-
#contentmodel(value) ⇒ self
Content model of the input text.
-
#disableeditsection ⇒ self
Omit edit section links from the parser output.
-
#disablelimitreport ⇒ self
Omit the limit report ("NewPP limit report") from the parser output.
-
#disablepp ⇒ self
Use disablelimitreport instead.
-
#disabletidy ⇒ self
Do not run HTML cleanup (e.g. tidy) on the parser output.
-
#disabletoc ⇒ self
Omit table of contents in output.
-
#effectivelanglinks ⇒ self
Includes language links supplied by extensions (for use with prop=langlinks).
-
#generatexml ⇒ self
Generate XML parse tree (requires content model wikitext; replaced by prop=parsetree).
-
#mainpage ⇒ self
Apply mobile main page transformations.
-
#mobileformat ⇒ self
Return parse output in a format suitable for mobile devices.
-
#noimages ⇒ self
Disable images in mobile output.
-
#oldid(value) ⇒ self
Parse the content of this revision.
-
#onlypst ⇒ self
Do a pre-save transform (PST) on the input, but don't parse it.
-
#page(value) ⇒ self
Parse the content of this page.
-
#pageid(value) ⇒ self
Parse the content of this page.
-
#preview ⇒ self
Parse in preview mode.
-
#prop(*values) ⇒ self
Which pieces of information to get:.
-
#pst ⇒ self
Do a pre-save transform on the input before parsing it.
-
#redirects ⇒ self
If page or pageid is set to a redirect, resolve it.
-
#section(value) ⇒ self
Only parse the content of this section number.
-
#sectionpreview ⇒ self
Parse in section preview mode (enables preview mode too).
-
#sectiontitle(value) ⇒ self
New section title when section is new.
-
#summary(value) ⇒ self
Summary to parse.
-
#templatesandboxcontentformat(value) ⇒ self
Content format of templatesandboxtext.
-
#templatesandboxcontentmodel(value) ⇒ self
Content model of templatesandboxtext.
-
#templatesandboxprefix(*values) ⇒ self
Template sandbox prefix, as with Special:TemplateSandbox.
-
#templatesandboxtext(value) ⇒ self
Parse the page using this page content in place of the page named by templatesandboxtitle.
-
#templatesandboxtitle(value) ⇒ self
Parse the page using templatesandboxtext in place of the contents of the page named here.
-
#text(value) ⇒ self
Text to parse.
-
#title(value) ⇒ self
Title of page the text belongs to.
Methods inherited from Get
Methods inherited from Base
#inspect, #merge, #name, #perform, #response, #to_h, #to_param, #to_url
Methods included from GlobalParams
#assert, #assertuser, #centralauthtoken, #curtimestamp, #errorformat, #errorlang, #errorsuselocal, #format, #maxage, #maxlag, #origin, #requestid, #responselanginfo, #servedby, #smaxage, #uselang
Instance Method Details
#contentformat(value) ⇒ self
Content serialization format used for the input text. Only valid when used with text.
187 188 189 |
# File 'lib/mediawiktory/wikipedia/actions/parse.rb', line 187 def contentformat(value) _contentformat(value) or fail ArgumentError, "Unknown value for contentformat: #{value}" end |
#contentmodel(value) ⇒ self
Content model of the input text. If omitted, title must be specified, and default will be the model of the specified title. Only valid when used with text.
200 201 202 |
# File 'lib/mediawiktory/wikipedia/actions/parse.rb', line 200 def contentmodel(value) _contentmodel(value) or fail ArgumentError, "Unknown value for contentmodel: #{value}" end |
#disableeditsection ⇒ self
Omit edit section links from the parser output.
144 145 146 |
# File 'lib/mediawiktory/wikipedia/actions/parse.rb', line 144 def disableeditsection() merge(disableeditsection: 'true') end |
#disablelimitreport ⇒ self
Omit the limit report ("NewPP limit report") from the parser output.
137 138 139 |
# File 'lib/mediawiktory/wikipedia/actions/parse.rb', line 137 def disablelimitreport() merge(disablelimitreport: 'true') end |
#disablepp ⇒ self
Use disablelimitreport instead.
130 131 132 |
# File 'lib/mediawiktory/wikipedia/actions/parse.rb', line 130 def disablepp() merge(disablepp: 'true') end |
#disabletidy ⇒ self
Do not run HTML cleanup (e.g. tidy) on the parser output.
151 152 153 |
# File 'lib/mediawiktory/wikipedia/actions/parse.rb', line 151 def disabletidy() merge(disabletidy: 'true') end |
#disabletoc ⇒ self
Omit table of contents in output.
179 180 181 |
# File 'lib/mediawiktory/wikipedia/actions/parse.rb', line 179 def disabletoc() merge(disabletoc: 'true') end |
#effectivelanglinks ⇒ self
Includes language links supplied by extensions (for use with prop=langlinks).
107 108 109 |
# File 'lib/mediawiktory/wikipedia/actions/parse.rb', line 107 def effectivelanglinks() merge(effectivelanglinks: 'true') end |
#generatexml ⇒ self
Generate XML parse tree (requires content model wikitext; replaced by prop=parsetree).
158 159 160 |
# File 'lib/mediawiktory/wikipedia/actions/parse.rb', line 158 def generatexml() merge(generatexml: 'true') end |
#mainpage ⇒ self
Apply mobile main page transformations.
226 227 228 |
# File 'lib/mediawiktory/wikipedia/actions/parse.rb', line 226 def mainpage() merge(mainpage: 'true') end |
#mobileformat ⇒ self
Return parse output in a format suitable for mobile devices.
212 213 214 |
# File 'lib/mediawiktory/wikipedia/actions/parse.rb', line 212 def mobileformat() merge(mobileformat: 'true') end |
#noimages ⇒ self
Disable images in mobile output.
219 220 221 |
# File 'lib/mediawiktory/wikipedia/actions/parse.rb', line 219 def noimages() merge(noimages: 'true') end |
#oldid(value) ⇒ self
Parse the content of this revision. Overrides page and pageid.
73 74 75 |
# File 'lib/mediawiktory/wikipedia/actions/parse.rb', line 73 def oldid(value) merge(oldid: value.to_s) end |
#onlypst ⇒ self
Do a pre-save transform (PST) on the input, but don't parse it. Returns the same wikitext, after a PST has been applied. Only valid when used with text.
100 101 102 |
# File 'lib/mediawiktory/wikipedia/actions/parse.rb', line 100 def onlypst() merge(onlypst: 'true') end |
#page(value) ⇒ self
Parse the content of this page. Cannot be used together with text and title.
50 51 52 |
# File 'lib/mediawiktory/wikipedia/actions/parse.rb', line 50 def page(value) merge(page: value.to_s) end |
#pageid(value) ⇒ self
Parse the content of this page. Overrides page.
58 59 60 |
# File 'lib/mediawiktory/wikipedia/actions/parse.rb', line 58 def pageid(value) merge(pageid: value.to_s) end |
#preview ⇒ self
Parse in preview mode.
165 166 167 |
# File 'lib/mediawiktory/wikipedia/actions/parse.rb', line 165 def preview() merge(preview: 'true') end |
#prop(*values) ⇒ self
Which pieces of information to get:
81 82 83 |
# File 'lib/mediawiktory/wikipedia/actions/parse.rb', line 81 def prop(*values) values.inject(self) { |res, val| res._prop(val) or fail ArgumentError, "Unknown value for prop: #{val}" } end |
#pst ⇒ self
Do a pre-save transform on the input before parsing it. Only valid when used with text.
93 94 95 |
# File 'lib/mediawiktory/wikipedia/actions/parse.rb', line 93 def pst() merge(pst: 'true') end |
#redirects ⇒ self
If page or pageid is set to a redirect, resolve it.
65 66 67 |
# File 'lib/mediawiktory/wikipedia/actions/parse.rb', line 65 def redirects() merge(redirects: 'true') end |
#section(value) ⇒ self
Only parse the content of this section number.
115 116 117 |
# File 'lib/mediawiktory/wikipedia/actions/parse.rb', line 115 def section(value) merge(section: value.to_s) end |
#sectionpreview ⇒ self
Parse in section preview mode (enables preview mode too).
172 173 174 |
# File 'lib/mediawiktory/wikipedia/actions/parse.rb', line 172 def sectionpreview() merge(sectionpreview: 'true') end |
#sectiontitle(value) ⇒ self
New section title when section is new.
123 124 125 |
# File 'lib/mediawiktory/wikipedia/actions/parse.rb', line 123 def sectiontitle(value) merge(sectiontitle: value.to_s) end |
#summary(value) ⇒ self
Summary to parse.
42 43 44 |
# File 'lib/mediawiktory/wikipedia/actions/parse.rb', line 42 def summary(value) merge(summary: value.to_s) end |
#templatesandboxcontentformat(value) ⇒ self
Content format of templatesandboxtext.
276 277 278 |
# File 'lib/mediawiktory/wikipedia/actions/parse.rb', line 276 def templatesandboxcontentformat(value) _templatesandboxcontentformat(value) or fail ArgumentError, "Unknown value for templatesandboxcontentformat: #{value}" end |
#templatesandboxcontentmodel(value) ⇒ self
Content model of templatesandboxtext.
263 264 265 |
# File 'lib/mediawiktory/wikipedia/actions/parse.rb', line 263 def templatesandboxcontentmodel(value) _templatesandboxcontentmodel(value) or fail ArgumentError, "Unknown value for templatesandboxcontentmodel: #{value}" end |
#templatesandboxprefix(*values) ⇒ self
Template sandbox prefix, as with Special:TemplateSandbox.
234 235 236 |
# File 'lib/mediawiktory/wikipedia/actions/parse.rb', line 234 def templatesandboxprefix(*values) values.inject(self) { |res, val| res._templatesandboxprefix(val) } end |
#templatesandboxtext(value) ⇒ self
Parse the page using this page content in place of the page named by templatesandboxtitle.
255 256 257 |
# File 'lib/mediawiktory/wikipedia/actions/parse.rb', line 255 def templatesandboxtext(value) merge(templatesandboxtext: value.to_s) end |
#templatesandboxtitle(value) ⇒ self
Parse the page using templatesandboxtext in place of the contents of the page named here.
247 248 249 |
# File 'lib/mediawiktory/wikipedia/actions/parse.rb', line 247 def templatesandboxtitle(value) merge(templatesandboxtitle: value.to_s) end |
#text(value) ⇒ self
Text to parse. Use title or contentmodel to control the content model.
34 35 36 |
# File 'lib/mediawiktory/wikipedia/actions/parse.rb', line 34 def text(value) merge(text: value.to_s) end |
#title(value) ⇒ self
Title of page the text belongs to. If omitted, contentmodel must be specified, and API will be used as the title.
26 27 28 |
# File 'lib/mediawiktory/wikipedia/actions/parse.rb', line 26 def title(value) merge(title: value.to_s) end |