Answers.Body: <p>I'd say that <a href="https://pandoc.org" rel="nofollow noreferrer">Pandoc</a>, an open source &quot;document universal converter&quot;, can be a very useful tool: have a look to its documentation. It allows to convert to and from many formats, including Markdown, <a href="https://djot.net/" rel="nofollow noreferrer">djot</a>, HTML, LaTeX,  in a highly customizable way...</p>
  <p>Conversion mechanism is relevant to the question:</p>
  <blockquote>
  <p>Pandoc has a modular design: it consists of a set of readers, which parse text in a given format and produce a native representation of the document (an abstract syntax tree or AST), and a set of writers, which convert this native representation into a target format. Thus, adding an input or output format requires only adding a reader or writer. Users can also run custom pandoc filters to modify the intermediate AST. (source: <a href="https://pandoc.org/MANUAL.html#description" rel="nofollow noreferrer">https://pandoc.org/MANUAL.html#description</a>)</p>
  </blockquote>
  <p>The intermediate representation is accessible (as &quot;native&quot; format), i.e. it's a sort of maximum of abstraction of structural elements. E.g., this markdown code</p>
  <pre><code># title
  
  text with *italic* and a footnote[^1]
  
  [^1]: footnote text
  </code></pre>
  <p>converts to</p>
  <pre><code>[ Header 1 ( &quot;title&quot; , [] , [] ) [ Str &quot;title&quot; ]
  , Para
      [ Str &quot;text&quot;
      , Space
      , Str &quot;with&quot;
      , Space
      , Emph [ Str &quot;italic&quot; ]
      , Space
      , Str &quot;and&quot;
      , Space
      , Str &quot;a&quot;
      , Space
      , Str &quot;footnote&quot;
      , Note [ Para [ Str &quot;footnote&quot; , Space , Str &quot;text&quot; ] ]
      ]
  ]
  </code></pre>
  <p>Anyway, it depends on your concrete needs and skills. For example, LaTeX can be very powerful (because it combines a sort of structural markup with the possibility of programmaticaly do things happen, and also because you can then convert your source with pandoc if needed), but it has a quite steep learning curve. Perhaps markdown and djot are nearest to an &quot;abstract&quot; markup. And keep in mind the difficulties mentioned by skreutzer.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-09-16T12:03:55.627Z
Answers.LastActivityDate: 2024-09-16T12:03:55.627Z
Answers.UserDisplayName: Iacobus1983
Answers.Body: <p>Technically, this is entirely possible (and done in fact by a number of publishers/companies/people). One related term/concept might be &quot;single-source publishing&quot;, which means, a number of output formats get generated from the same &quot;universal&quot; source.</p>
  <p>There's a number of difficulties thought. If you truly represent every little detail with it's own special markers which may also be local/specific to the context of the document, it could potentially mean that, in order to accurately represent the document in a more consumable format and to support all the specific extra features, you might need to add a lot of custom, unique styles, which then might not be reusable for any other document/context.</p>
  <p>Also, document features might not necessarily all too compatible. Links in the source are fine to be clickable for a Web HTML export, likely fine in an e-ink e-reader too (except no guarantees there's Internet connectivity), but they may wrap/display poorly on printout and wouldn't be clickable anyway, and then there's also a difference for what you would want as link caption as compared to a link in printed text, where it's probably better as a footnote/endnote. Many little details like that.</p>
  <p>If HTML is fine, then it's especially easy, because HTML (for Web documents) is part of the XML family (or say, HTML created in the XHTML fashion, which means it's XML-compliant/-compatible), and with XML, you can mix XML formats, as well as add/introduce your own custom formats, to then use XML tooling to extract/react to what's in the file. There's a whole range of XML formats to support various aspects of structuring text, for example take a look at TEI (Text Encoding Initiative).</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-12-17T00:43:16.193Z
Answers.LastActivityDate: 2022-12-17T00:43:16.193Z
Answers.UserDisplayName: skreutzer
Answers.Body: <p>Reasonable dream with XML trees. The extremely unreasonable nightmare version of your dream would be then uniting the trees with pure vector graphics via writing them in postscript instead, either XML first and converting to it, or having postscript format in your head, somehow connected to human language. Crikey.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-10-08T04:55:57.190Z
Answers.LastActivityDate: 2024-10-08T04:55:57.190Z
Answers.UserDisplayName: tufted_titmouse_nwk
Body: <p>I was recently thinking about preparing a document, and if I could structure the information of that document in the most universal way possible. Ideally, document elements should be tagged as what they are - header, tagline, chapter, etc. Naturally, there is variation from document to document, so people can make their own tag labels.</p>
  <p>Basically, this is just HTML, except I wanted to be sure every piece of information was tagged and structured, so that the formatting of the abstract “text information / data structure” could be switched between many types instantly, with no need for modifying.</p>
  <p>That just means that sentences should also be tagged, not just paragraphs with <p> tags, and ideally, any kind of diagram or figure is easy to break into pieces, to modularize, as well. Why? Because the point of this format is that everything, every element, is identified on the smallest possible level, so that for different formats, you can design a different system for displaying that data structure in that medium.</p>
  <p>So, imagine we have this abstract document markup - title, author, section, paragraph, sentence, list, table, table header, etc.</p>
  <p>Ideally, we can just plug it in to some style/formatting package to make a new type of presentation - it can be a webpage - it can be a single piece of paper, like a large kind of research presentation poster - it can be a paginated book - it can be a PowerPoint presentation - it can be an automatically generated video - it can even be an interactive reading application where you navigate through pressing “next” or “back” - etc. Each format knows how to handle the “universal markup”. For example, the universal markup may include a citation for a sentence - or it may include a link, for a word. The formats would know that in a book, citations can be at the bottom; in an interactive reader, they can be omitted; on a website, perhaps they could be expressed as hyperlinks on that text, or a parentheses at the end of the sentence (“see here”). Whereas a hyperlink in a document would be expressed normally, in a book, it could either be a footnote, omitted, or maybe an annotation blurb in the margins. And so on.</p>
  <p>So: has anyone considered a minor extension to HTML focusing on explicitly tagging all elements with their abstract function or role in the document could be a universal document markup language to easily be formatted in myriad ways?</p>
  
Tags: <html><formatting>
Title: Can you typeset documents in a universal markup language?
UserDisplayName: Julius Hamilton
ThreadText: # Can you typeset documents in a universal markup language?
  
  (Asked by: username_0 on 2022-11-27)
  
  I was recently thinking about preparing a document, and if I could structure the information of that document in the most universal way possible. Ideally, document elements should be tagged as what they are - header, tagline, chapter, etc. Naturally, there is variation from document to document, so people can make their own tag labels.
  
  Basically, this is just HTML, except I wanted to be sure every piece of information was tagged and structured, so that the formatting of the abstract “text information / data structure” could be switched between many types instantly, with no need for modifying.
  
  That just means that sentences should also be tagged, not just paragraphs with
  
  tags, and ideally, any kind of diagram or figure is easy to break into pieces, to modularize, as well. Why? Because the point of this format is that everything, every element, is identified on the smallest possible level, so that for different formats, you can design a different system for displaying that data structure in that medium.
  
  So, imagine we have this abstract document markup - title, author, section, paragraph, sentence, list, table, table header, etc.
  
  Ideally, we can just plug it in to some style/formatting package to make a new type of presentation - it can be a webpage - it can be a single piece of paper, like a large kind of research presentation poster - it can be a paginated book - it can be a PowerPoint presentation - it can be an automatically generated video - it can even be an interactive reading application where you navigate through pressing “next” or “back” - etc. Each format knows how to handle the “universal markup”. For example, the universal markup may include a citation for a sentence - or it may include a link, for a word. The formats would know that in a book, citations can be at the bottom; in an interactive reader, they can be omitted; on a website, perhaps they could be expressed as hyperlinks on that text, or a parentheses at the end of the sentence (“see here”). Whereas a hyperlink in a document would be expressed normally, in a book, it could either be a footnote, omitted, or maybe an annotation blurb in the margins. And so on.
  
  So: has anyone considered a minor extension to HTML focusing on explicitly tagging all elements with their abstract function or role in the document could be a universal document markup language to easily be formatted in myriad ways?
  
  **Tags:** html, formatting
  
  
  ---
  
  ## 3 answers
  
  ### Answer by username_1 on 2024-09-16. Score: 1 | Accepted answer
  
  I'd say that Pandoc, an open source "document universal converter", can be a very useful tool: have a look to its documentation. It allows to convert to and from many formats, including Markdown, djot, HTML, LaTeX,  in a highly customizable way...
  Conversion mechanism is relevant to the question:
  
  Pandoc has a modular design: it consists of a set of readers, which parse text in a given format and produce a native representation of the document (an abstract syntax tree or AST), and a set of writers, which convert this native representation into a target format. Thus, adding an input or output format requires only adding a reader or writer. Users can also run custom pandoc filters to modify the intermediate AST. (source: https://pandoc.org/MANUAL.html#description)
  
  The intermediate representation is accessible (as "native" format), i.e. it's a sort of maximum of abstraction of structural elements. E.g., this markdown code
  # title
  
  text with *italic* and a footnote[^1]
  
  [^1]: footnote text
  
  converts to
  [ Header 1 ( "title" , [] , [] ) [ Str "title" ]
  , Para
      [ Str "text"
      , Space
      , Str "with"
      , Space
      , Emph [ Str "italic" ]
      , Space
      , Str "and"
      , Space
      , Str "a"
      , Space
      , Str "footnote"
      , Note [ Para [ Str "footnote" , Space , Str "text" ] ]
      ]
  ]
  
  Anyway, it depends on your concrete needs and skills. For example, LaTeX can be very powerful (because it combines a sort of structural markup with the possibility of programmaticaly do things happen, and also because you can then convert your source with pandoc if needed), but it has a quite steep learning curve. Perhaps markdown and djot are nearest to an "abstract" markup. And keep in mind the difficulties mentioned by username_2.
  
  
  ---
  
  ### Answer by username_2 on 2022-12-17. Score: 1
  
  Technically, this is entirely possible (and done in fact by a number of publishers/companies/people). One related term/concept might be "single-source publishing", which means, a number of output formats get generated from the same "universal" source.
  
  There's a number of difficulties thought. If you truly represent every little detail with it's own special markers which may also be local/specific to the context of the document, it could potentially mean that, in order to accurately represent the document in a more consumable format and to support all the specific extra features, you might need to add a lot of custom, unique styles, which then might not be reusable for any other document/context.
  
  Also, document features might not necessarily all too compatible. Links in the source are fine to be clickable for a Web HTML export, likely fine in an e-ink e-reader too (except no guarantees there's Internet connectivity), but they may wrap/display poorly on printout and wouldn't be clickable anyway, and then there's also a difference for what you would want as link caption as compared to a link in printed text, where it's probably better as a footnote/endnote. Many little details like that.
  
  If HTML is fine, then it's especially easy, because HTML (for Web documents) is part of the XML family (or say, HTML created in the XHTML fashion, which means it's XML-compliant/-compatible), and with XML, you can mix XML formats, as well as add/introduce your own custom formats, to then use XML tooling to extract/react to what's in the file. There's a whole range of XML formats to support various aspects of structuring text, for example take a look at TEI (Text Encoding Initiative).
  
  
  ---
  
  ### Answer by username_3 on 2024-10-08. Score: 0
  
  Reasonable dream with XML trees. The extremely unreasonable nightmare version of your dream would be then uniting the trees with pure vector graphics via writing them in postscript instead, either XML first and converting to it, or having postscript format in your head, somehow connected to human language. Crikey.
  
  
  ---
  
  