Sandbox:Temp: Difference between revisions
Sandbox demo: semantic content model demonstration (entities, dynamic rendering, citations, embeds, sitelink) (via update-page on MediaWiki MCP Server) Tag: Reverted |
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 |
||
| Line 3: | Line 3: | ||
== Freedom begins under this line == | == Freedom begins under this line == | ||
This page | 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. | ||
The | === 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" | {| class="wikitable" | ||
! Kind !! Item !! Live data rendered from statements | ! 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: | | 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. | === 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.) | |||
<code> | |||
==== | ==== 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 === | === 4. Citations and bibliography === | ||
The | 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> | ||
Babbage | 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 ==== | ==== Bibliography ==== | ||
<references/> | <references/> | ||
==== Sources collected automatically ==== | ==== Sources collected automatically ==== | ||
The <nowiki>{{#citations:}}</nowiki> collector gathers the same | The <nowiki>{{#citations:}}</nowiki> collector gathers the same sources here — deduplicated across the inline citations above and the embed URLs in § 3: | ||
{{#citations:}} | {{#citations:}} | ||
| Line 69: | Line 57: | ||
=== 5. Try it yourself === | === 5. Try it yourself === | ||
* Open [[Item: | * 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]]. | |||
* See the help pages: [[Help:Contributing/ | |||
Revision as of 11:33, 30 August 2026
This is a scratch page. You can do whatever to it below 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
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. Factorial in Python) were single-line only, squeezed onto one line; this one keeps its real shape.
| Kind | Item | Live data rendered from statements |
|---|---|---|
| Code snippet | Bernoulli numbers in Python | instance of: code snippet · language: Python · attributed to: Ada Lovelace · source: Notes by the Translator |
| Person | Ada Lovelace | instance of: person |
| Book (citable source) | Notes by the Translator | author: Ada Lovelace · publisher: R. & J. E. Taylor · year: 1843 |
2. How the payload is stored
The stored statement escapes each line break as a two-character \n sequence (and \t for tabs, \r for carriage returns, \\ for backslashes — backslashes first, so a literal \n inside the code survives the round trip). The {{#statements:}} parser function shows the raw, escaped value — one long line, exactly what storage holds:
from fractions import Fraction\n\ndef bernoulli(n):\n """Return the nth Bernoulli number (Akiyama-Tanigawa algorithm)."""\n A = [Fraction(0)] * (n + 1)\n for m in range(n + 1):\n A[m] = Fraction(1, m + 1)\n for j in range(m, 0, -1):\n A[j - 1] = j * (A[j - 1] - A[j])\n return A[0]\n\nprint([str(bernoulli(n)) for n in range(8)])
3. How it renders
The embed surface
The standalone embed decodes the payload — real line breaks, no escape sequences: rendered embed. (The sanitizer strips iframe 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 {{#content:}} parser function is the on-wiki decoder — it returns the same payload with the escapes undone:
from fractions import Fraction
def bernoulli(n):
"""Return the nth Bernoulli number (Akiyama-Tanigawa algorithm)."""
A = [Fraction(0)] * (n + 1)
for m in range(n + 1):
A[m] = Fraction(1, m + 1)
for j in range(m, 0, -1):
A[j - 1] = j * (A[j - 1] - A[j])
return A[0]
print([str(bernoulli(n)) for n in range(8)])That is the decoded payload rendered live: each line of the program is on its own line, indentation preserved, no \n in sight.
4. Citations and bibliography
The snippet's source, Notes by the Translator (Ada Lovelace, 1843), is cited inline:[1] 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.[1]
The Babbage quotation Pray, Mr. Babbage, … embeds the same way: rendered embed — its source is collected automatically too.
Bibliography
Sources collected automatically
The {{#citations:}} collector gathers the same sources here — deduplicated across the inline citations above and the embed URLs in § 3:
- Lovelace, A. (1843). Notes by the Translator. In Notes by the Translator. R. & J. E. Taylor. https://doi.org/10.1000/notes
- Babbage, C. (1864). Passages from the Life of a Philosopher. In Passages from the Life of a Philosopher. Longman.
5. Try it yourself
- Open Item:Q1129 and edit its
code sourcestatement — § 3 updates immediately. - See the help pages: Help:Contributing/code, Help:Contributing/citations, Help:Contributing/semanticDynamicContent, Help:Contributing/quotation, Help:Contributing/math.