Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PDF: Semantic elements in Presentation XML #645

Closed
Tracked by #418
opoudjis opened this issue Feb 6, 2025 · 6 comments
Closed
Tracked by #418

PDF: Semantic elements in Presentation XML #645

opoudjis opened this issue Feb 6, 2025 · 6 comments
Assignees
Labels
enhancement New feature or request

Comments

@opoudjis
Copy link
Contributor

opoudjis commented Feb 6, 2025

#642

date is currently replaced by a rendering in PresentationXML. The semantic elements need to be retained, and the renderings indexed with semx under fmt-date. Ignore the newly appearing date element in Presentation XML:

<date format="%m/%d/%Y" value="2021-01-03" id="A"/>
<fmt-date><semx element="date" source="A">3/1/2021</semx></fmt-date>

MathML math//mn is addressed in two ways in Presentation XML, when there is a number formatting specification:

  • If mn is the only content in the math element, it is replaced by the formatted number as a string: processing it under MathML is unnecessary for rendering, and ends up prohibitive for large numbers of math/mn
  • If there are mn elements interleaved with other content, their content is replaced with formatted numbers

So we will have in general a fmt-stem rendering for each stem; its content may be a string, in the case of mn as the only content, or a replication of the MathML, if not. stem is to be ignored in processing in favour of fmt-stem, and it will be a sister node not a child node. So:

<stem type="MathML" id="A"><math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle><mn>64212149677264515</mn></mstyle></math></stem>
<fmt-stem><semx element="stem" source="A">64,212,149,677,264,515</semx></fmt-stem>

<stem type="MathML" id="B"><math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mn>1000</mn><mo>−</mo><mi>j</mi></mrow>
</math></stem>
<fmt-stem><semx element="stem" source="B">
<math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mn>1,000</mn><mo>−</mo><mi>j</mi></mrow>
</math></semx></fmt-stem>
@opoudjis opoudjis added the enhancement New feature or request label Feb 6, 2025
@github-project-automation github-project-automation bot moved this to 🆕 New in Metanorma Feb 6, 2025
@Intelligent2013 Intelligent2013 moved this from 🆕 New to 🏗 In progress in Metanorma Feb 10, 2025
@Intelligent2013
Copy link
Contributor

Gemfile update for testing:

gem "isodoc", git: "https://github.com/metanorma/isodoc", branch: "fix/fmt-date-number"

Intelligent2013 added a commit to metanorma/metanorma.org that referenced this issue Feb 10, 2025
@Intelligent2013
Copy link
Contributor

@opoudjis is there any working example of the date command?
I've tried the example from https://www.metanorma.org/author/topics/inline_markup/semantic-elements/#dates:

date[2012-02-02]

but the Presentation XML contains just a text 'as is'

Test date[2012-02-02, %A %d %B].

Actually, the colon is missing after date (I've update the documentation in metanorma/metanorma.org#842). But the adoc:

Test date:[2012-02-02].

occurs the error:

C:/tools/ruby31/lib/ruby/gems/3.1.0/gems/isodoc-i18n-1.3.1/lib/isodoc/i18n.rb:42:in `block (2 levels) in init_labels'
C:/tools/ruby31/lib/ruby/gems/3.1.0/gems/isodoc-2.12.9/lib/isodoc/presentation_function/inline.rb:107:in `date1'
C:/tools/ruby31/lib/ruby/gems/3.1.0/gems/isodoc-2.12.9/lib/isodoc/presentation_function/inline.rb:101:in `block in date'
C:/tools/ruby31/lib/ruby/gems/3.1.0/gems/nokogiri-1.16.8-x64-mingw-ucrt/lib/nokogiri/xml/node_set.rb:235:in `block in each'
C:/tools/ruby31/lib/ruby/gems/3.1.0/gems/nokogiri-1.16.8-x64-mingw-ucrt/lib/nokogiri/xml/node_set.rb:234:in `upto'
C:/tools/ruby31/lib/ruby/gems/3.1.0/gems/nokogiri-1.16.8-x64-mingw-ucrt/lib/nokogiri/xml/node_set.rb:234:in `each'
C:/tools/ruby31/lib/ruby/gems/3.1.0/gems/isodoc-2.12.9/lib/isodoc/presentation_function/inline.rb:100:in `date'
C:/tools/ruby31/lib/ruby/gems/3.1.0/gems/isodoc-2.12.9/lib/isodoc/presentation_xml_convert.rb:105:in `inline'
C:/tools/ruby31/lib/ruby/gems/3.1.0/gems/isodoc-2.12.9/lib/isodoc/presentation_xml_convert.rb:49:in `conversions'
C:/tools/ruby31/lib/ruby/gems/3.1.0/gems/isodoc-2.12.9/lib/isodoc/presentation_xml_convert.rb:29:in `convert1'
C:/tools/ruby31/lib/ruby/gems/3.1.0/gems/metanorma-iso-2.9.6/lib/isodoc/iso/presentation_xml_convert.rb:22:in `convert1'
C:/tools/ruby31/lib/ruby/gems/3.1.0/gems/isodoc-2.12.9/lib/isodoc/convert.rb:147:in `convert'
C:/tools/ruby31/lib/ruby/gems/3.1.0/gems/metanorma-iso-2.9.6/lib/metanorma/iso/processor.rb:68:in `output'
C:/tools/ruby31/lib/ruby/gems/3.1.0/gems/metanorma-2.0.11/lib/metanorma/compile/compile.rb:193:in `process_output_unthreaded
C:/tools/ruby31/lib/ruby/gems/3.1.0/gems/metanorma-2.0.11/lib/metanorma/compile/compile.rb:179:in `process_exts1'
C:/tools/ruby31/lib/ruby/gems/3.1.0/gems/metanorma-2.0.11/lib/metanorma/compile/compile.rb:152:in `process_ext'
C:/tools/ruby31/lib/ruby/gems/3.1.0/gems/metanorma-2.0.11/lib/metanorma/compile/compile.rb:118:in `process_exts'
C:/tools/ruby31/lib/ruby/gems/3.1.0/gems/metanorma-2.0.11/lib/metanorma/compile/compile.rb:35:in `compile'
C:/tools/ruby31/lib/ruby/gems/3.1.0/gems/metanorma-cli-1.11.6/lib/metanorma/cli/compiler.rb:45:in `compile_file'
C:/tools/ruby31/lib/ruby/gems/3.1.0/gems/metanorma-cli-1.11.6/lib/metanorma/cli/compiler.rb:30:in `compile'
C:/tools/ruby31/lib/ruby/gems/3.1.0/gems/metanorma-cli-1.11.6/lib/metanorma/cli/compiler.rb:35:in `compile'
C:/tools/ruby31/lib/ruby/gems/3.1.0/gems/metanorma-cli-1.11.6/lib/metanorma/cli/command.rb:272:in `compile_document'
C:/tools/ruby31/lib/ruby/gems/3.1.0/gems/metanorma-cli-1.11.6/lib/metanorma/cli/command.rb:62:in `block in compile'
C:/tools/ruby31/lib/ruby/gems/3.1.0/gems/metanorma-cli-1.11.6/lib/metanorma/cli/command.rb:62:in `each'
C:/tools/ruby31/lib/ruby/gems/3.1.0/gems/metanorma-cli-1.11.6/lib/metanorma/cli/command.rb:62:in `compile'
C:/tools/ruby31/lib/ruby/gems/3.1.0/gems/thor-1.3.2/lib/thor/command.rb:28:in `run'
C:/tools/ruby31/lib/ruby/gems/3.1.0/gems/thor-hollaback-0.2.1/lib/thor/hollaback.rb:68:in `run'
C:/tools/ruby31/lib/ruby/gems/3.1.0/gems/thor-1.3.2/lib/thor/invocation.rb:127:in `invoke_command'
C:/tools/ruby31/lib/ruby/gems/3.1.0/gems/thor-1.3.2/lib/thor.rb:538:in `dispatch'
C:/tools/ruby31/lib/ruby/gems/3.1.0/gems/thor-1.3.2/lib/thor/base.rb:584:in `start'
C:/tools/ruby31/lib/ruby/gems/3.1.0/gems/metanorma-cli-1.11.6/lib/metanorma/cli.rb:34:in `start'
C:/tools/ruby31/lib/ruby/gems/3.1.0/gems/metanorma-cli-1.11.6/exe/metanorma:25:in `block in <top (required)>'
C:/tools/ruby31/lib/ruby/gems/3.1.0/gems/metanorma-cli-1.11.6/exe/metanorma:43:in `<top (required)>'
C:/tools/ruby31/lib/ruby/gems/3.1.0/bin/metanorma:25:in `load'
C:/tools/ruby31/lib/ruby/gems/3.1.0/bin/metanorma:25:in `<main>'
wrong number of arguments (given 2, expected 0)

even with the original Gemfile:

source "https://rubygems.org"

gem "metanorma-cli"

ronaldtse pushed a commit to metanorma/metanorma.org that referenced this issue Feb 10, 2025
@Intelligent2013
Copy link
Contributor

XSLTs don't have the special processing for date.
date in the new Presentation XML is empty (no text element inside). fmt-date will be rendered just a text. So, no need to update XSLTs for dates.

Intelligent2013 added a commit to metanorma/mn-native-pdf that referenced this issue Feb 10, 2025
@Intelligent2013
Copy link
Contributor

XSLT updated for fmt-stem in metanorma/mn-native-pdf#816. PR is ready to merge.
Done.

@Intelligent2013 Intelligent2013 moved this from 🏗 In progress to ✅ Done in Metanorma Feb 10, 2025
Intelligent2013 added a commit to metanorma/mn-native-pdf that referenced this issue Feb 10, 2025
opoudjis added a commit to metanorma/mn-native-pdf that referenced this issue Feb 12, 2025
@opoudjis
Copy link
Contributor Author

opoudjis commented Feb 13, 2025

Sorry, I tuned out on this bug report. Yes, it results from ISO using date as a label, conflicting with isodoc-i18n using date as a function. Will fix in metanorma/isodoc-i18n#12

@opoudjis is there any working example of the date command? I've tried the example from https://www.metanorma.org/author/topics/inline_markup/semantic-elements/#dates:

date[2012-02-02]

but the Presentation XML contains just a text 'as is'

Test date[2012-02-02, %A %d %B].

Actually, the colon is missing after date (I've update the documentation in metanorma/metanorma.org#842). But the adoc:

Test date:[2012-02-02].

occurs the error:

C:/tools/ruby31/lib/ruby/gems/3.1.0/gems/isodoc-i18n-1.3.1/lib/isodoc/i18n.rb:42:in `block (2 levels) in init_labels'
C:/tools/ruby31/lib/ruby/gems/3.1.0/gems/isodoc-2.12.9/lib/isodoc/presentation_function/inline.rb:107:in `date1'
C:/tools/ruby31/lib/ruby/gems/3.1.0/gems/isodoc-2.12.9/lib/isodoc/presentation_function/inline.rb:101:in `block in date'
C:/tools/ruby31/lib/ruby/gems/3.1.0/gems/nokogiri-1.16.8-x64-mingw-ucrt/lib/nokogiri/xml/node_set.rb:235:in `block in each'
C:/tools/ruby31/lib/ruby/gems/3.1.0/gems/nokogiri-1.16.8-x64-mingw-ucrt/lib/nokogiri/xml/node_set.rb:234:in `upto'
C:/tools/ruby31/lib/ruby/gems/3.1.0/gems/nokogiri-1.16.8-x64-mingw-ucrt/lib/nokogiri/xml/node_set.rb:234:in `each'
C:/tools/ruby31/lib/ruby/gems/3.1.0/gems/isodoc-2.12.9/lib/isodoc/presentation_function/inline.rb:100:in `date'
C:/tools/ruby31/lib/ruby/gems/3.1.0/gems/isodoc-2.12.9/lib/isodoc/presentation_xml_convert.rb:105:in `inline'
C:/tools/ruby31/lib/ruby/gems/3.1.0/gems/isodoc-2.12.9/lib/isodoc/presentation_xml_convert.rb:49:in `conversions'
C:/tools/ruby31/lib/ruby/gems/3.1.0/gems/isodoc-2.12.9/lib/isodoc/presentation_xml_convert.rb:29:in `convert1'
C:/tools/ruby31/lib/ruby/gems/3.1.0/gems/metanorma-iso-2.9.6/lib/isodoc/iso/presentation_xml_convert.rb:22:in `convert1'
C:/tools/ruby31/lib/ruby/gems/3.1.0/gems/isodoc-2.12.9/lib/isodoc/convert.rb:147:in `convert'
C:/tools/ruby31/lib/ruby/gems/3.1.0/gems/metanorma-iso-2.9.6/lib/metanorma/iso/processor.rb:68:in `output'
C:/tools/ruby31/lib/ruby/gems/3.1.0/gems/metanorma-2.0.11/lib/metanorma/compile/compile.rb:193:in `process_output_unthreaded
C:/tools/ruby31/lib/ruby/gems/3.1.0/gems/metanorma-2.0.11/lib/metanorma/compile/compile.rb:179:in `process_exts1'
C:/tools/ruby31/lib/ruby/gems/3.1.0/gems/metanorma-2.0.11/lib/metanorma/compile/compile.rb:152:in `process_ext'
C:/tools/ruby31/lib/ruby/gems/3.1.0/gems/metanorma-2.0.11/lib/metanorma/compile/compile.rb:118:in `process_exts'
C:/tools/ruby31/lib/ruby/gems/3.1.0/gems/metanorma-2.0.11/lib/metanorma/compile/compile.rb:35:in `compile'
C:/tools/ruby31/lib/ruby/gems/3.1.0/gems/metanorma-cli-1.11.6/lib/metanorma/cli/compiler.rb:45:in `compile_file'
C:/tools/ruby31/lib/ruby/gems/3.1.0/gems/metanorma-cli-1.11.6/lib/metanorma/cli/compiler.rb:30:in `compile'
C:/tools/ruby31/lib/ruby/gems/3.1.0/gems/metanorma-cli-1.11.6/lib/metanorma/cli/compiler.rb:35:in `compile'
C:/tools/ruby31/lib/ruby/gems/3.1.0/gems/metanorma-cli-1.11.6/lib/metanorma/cli/command.rb:272:in `compile_document'
C:/tools/ruby31/lib/ruby/gems/3.1.0/gems/metanorma-cli-1.11.6/lib/metanorma/cli/command.rb:62:in `block in compile'
C:/tools/ruby31/lib/ruby/gems/3.1.0/gems/metanorma-cli-1.11.6/lib/metanorma/cli/command.rb:62:in `each'
C:/tools/ruby31/lib/ruby/gems/3.1.0/gems/metanorma-cli-1.11.6/lib/metanorma/cli/command.rb:62:in `compile'
C:/tools/ruby31/lib/ruby/gems/3.1.0/gems/thor-1.3.2/lib/thor/command.rb:28:in `run'
C:/tools/ruby31/lib/ruby/gems/3.1.0/gems/thor-hollaback-0.2.1/lib/thor/hollaback.rb:68:in `run'
C:/tools/ruby31/lib/ruby/gems/3.1.0/gems/thor-1.3.2/lib/thor/invocation.rb:127:in `invoke_command'
C:/tools/ruby31/lib/ruby/gems/3.1.0/gems/thor-1.3.2/lib/thor.rb:538:in `dispatch'
C:/tools/ruby31/lib/ruby/gems/3.1.0/gems/thor-1.3.2/lib/thor/base.rb:584:in `start'
C:/tools/ruby31/lib/ruby/gems/3.1.0/gems/metanorma-cli-1.11.6/lib/metanorma/cli.rb:34:in `start'
C:/tools/ruby31/lib/ruby/gems/3.1.0/gems/metanorma-cli-1.11.6/exe/metanorma:25:in `block in <top (required)>'
C:/tools/ruby31/lib/ruby/gems/3.1.0/gems/metanorma-cli-1.11.6/exe/metanorma:43:in `<top (required)>'
C:/tools/ruby31/lib/ruby/gems/3.1.0/bin/metanorma:25:in `load'
C:/tools/ruby31/lib/ruby/gems/3.1.0/bin/metanorma:25:in `<main>'
wrong number of arguments (given 2, expected 0)

even with the original Gemfile:

source "https://rubygems.org"

gem "metanorma-cli"

Intelligent2013 added a commit to metanorma/mn-native-pdf that referenced this issue Feb 13, 2025
@Intelligent2013
Copy link
Contributor

Will fix in metanorma/isodoc-i18n#12

@opoudjis confirmed. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Done
Development

No branches or pull requests

2 participants