From: Schimon J. <sc...@fe...> - 2025-07-26 18:23:15
|
On Sat, 26 Jul 2025 08:06:50 -0000 (UTC) Guenter Milde via Docutils-users <doc...@li...> wrote: > On 2025-07-25, Schimon Jehudah via Docutils-users wrote: > > Good day. > > > Is it feasible to set the routine (i.e. default) element to "span", > > or any other element, instead of element "p"? > > Isn't this what XSLT is made for? > I meant, that the produced output of docutils utilizes the tag "p". > > >>>> from docutils.core import publish_parts > >>>> publish_parts(source="This an XHTML text with a `link > >>>> <https://movim.eu>`_ for XMPP PubSub", > >>>> writer_name="xhtml")["fragment\ > > "] > > '<p>This an XHTML text with a <a class="reference external" > > href="https://movim.eu">link</a> for XMPP PubSub</p>\n' > > When processing Docutils output with XSLT, you may consider using > Docutils native XML format as starting point. HTML is missing several > features of Docutils documents (e.g. footnotes) that must be > emulated. Starting from Docutils XML saves you from reverse > engineering. > > See https://docutils.sourceforge.io/docs/ref/docutils.dtd > and https://docutils.sourceforge.io/docs/ref/doctree.html. > > :: > > from docutils.core import publish_string > publish_string(source="Text with link: https://example.org", > writer_name="xml", > settings_overrides={"indents": True, > "output_encoding": "unicode"}) > > With the upcoming Docutils 0.22, you will be able to re-read the > processed Docutils XML with the "xml" parser and export to all > supported formats. > This is done separately. Docutils is utilized to convert reStructuredText to XHTML, and then LXML is utilized to incorporate that output to XSLT. https://git.xmpp-it.net/sch/Rivista/src/branch/main/rivista/interface/http.py https://git.xmpp-it.net/sch/Rivista/src/branch/main/rivista/utility/rst.py https://git.xmpp-it.net/sch/Rivista/src/branch/main/rivista/parser/xml.py Should XML output be utilized, would links be realized with the tag "a"? > If you want HTML output from Docutils, you may consider the more > modern "html5" writer. Both, the "xhtml" writer and the "html5" > writer emit HTML that is also valid XML. However the "xhtml" writer > (an alias for "html4css1") is less semantic in its output. > (On the other hand, the "xhtml" writer is more stable, because it is > mainly kept for backwards compatibility.) > > Günter > I will try the option of XHTML. Thank you, Schimon. |