Sandbox:Temp: Difference between revisions

From Wikibase
Jump to navigation Jump to search
Demonstrate multi-line content end-to-end: Q1129 (Bernoulli numbers in Python), storage encoding vs decoded rendering, citations + bibliography (via update-page on MediaWiki MCP Server)
Tag: Reverted
Tag: Manual revert
 
(One intermediate revision by the same user not shown)
Line 2: Line 2:


== Freedom begins under this line ==
== Freedom begins under this line ==
This page demonstrates the instance's '''multi-line content''' capability: content items (quotations, math, code) can now hold genuinely multi-line payloads. Multi-line payloads are stored '''backslash-escaped''' — the wiki's string values reject raw line breaks — and '''decoded at render time'''. Everything below is live data: edit the item and this page updates by itself.
=== 1. The multi-line item ===
[[Item:Q1129|Bernoulli numbers in Python]] is a code-snippet item whose payload is a real 12-line Python program — an Akiyama–Tanigawa computation of the Bernoulli numbers, echoing the algorithm Ada Lovelace sketched in her 1843 note. Earlier code items (e.g. [[Item:Q99|Factorial in Python]]) were single-line only, squeezed onto one line; this one keeps its real shape.
{| class="wikitable"
! Kind !! Item !! Live data rendered from statements
|-
| Code snippet || [[Item:Q1129|Bernoulli numbers in Python]] || instance of: {{#statements:P1|from=Q1129}} · language: {{#statements:P5|from=Q1129}} · attributed to: {{#statements:P6|from=Q1129}} · source: {{#statements:P28|from=Q1129}}
|-
| Person || [[Item:Q94|Ada Lovelace]] || instance of: {{#statements:P1|from=Q94}}
|-
| Book (citable source) || [[Item:Q95|Notes by the Translator]] || author: {{#statements:P6|from=Q95}} · publisher: {{#statements:P54|from=Q95}} · year: {{#statements:P8|from=Q95}}
|}
=== 2. How the payload is stored ===
The stored statement escapes each line break as a two-character <code>\n</code> sequence (and <code>\t</code> for tabs, <code>\r</code> for carriage returns, <code>\\</code> for backslashes — backslashes first, so a literal <code>\n</code> inside the code survives the round trip). The <nowiki>{{#statements:}}</nowiki> parser function shows the raw, escaped value — one long line, exactly what storage holds:
<code>{{#statements:P3|from=Q1129}}</code>
=== 3. How it renders ===
==== The embed surface ====
The standalone embed decodes the payload — real line breaks, no escape sequences: [https://wikibase.ronzz.org/wiki/Special:Embed/Q1129 rendered embed]. (The sanitizer strips <code>iframe</code> tags from wiki pages, so on-wiki the reliable surface is this URL — which also feeds the citation auto-collect in § 4.)
==== On this page ====
The <nowiki>{{#content:}}</nowiki> parser function is the on-wiki decoder — it returns the same payload with the escapes undone:
<div style="border:1px solid #c8ccd1; border-left:4px solid #36c; padding:0.75em 1em; background:#f8f9fa;">{{#content:Q1129}}</div>
That is the decoded payload rendered live: each line of the program is on its own line, indentation preserved, no <code>\n</code> in sight.
=== 4. Citations and bibliography ===
The snippet's source, [[Item:Q95|Notes by the Translator]] (Ada Lovelace, 1843), is cited inline:<ref>{{#cite:Q95}}</ref> Lovelace's note described the computation of Bernoulli numbers on the Analytical Engine — widely regarded as the first published computer program, and the direct inspiration for this snippet.<ref>{{#cite:Q95}}</ref>
The Babbage quotation [[Item:Q1086|Pray, Mr. Babbage, …]] embeds the same way: [https://wikibase.ronzz.org/wiki/Special:Embed/Q1086 rendered embed] — its source is collected automatically too.
==== Bibliography ====
<references/>
==== Sources collected automatically ====
The <nowiki>{{#citations:}}</nowiki> collector gathers the same sources here — deduplicated across the inline citations above and the embed URLs in § 3:
{{#citations:}}
=== 5. Try it yourself ===
* Open [[Item:Q1129]] and edit its <code>code source</code> statement — § 3 updates immediately.
* See the help pages: [[Help:Contributing/code]], [[Help:Contributing/citations]], [[Help:Contributing/semanticDynamicContent]], [[Help:Contributing/quotation]], [[Help:Contributing/math]].

Latest revision as of 11:53, 19 September 2026

Languages: English · français · Esperanto

This is a scratch page. You can do whatever to it below this line

Freedom begins under this line