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

Metanorma attachments not working (absolute path, failiure in encoding) #898

Closed
ronaldtse opened this issue Jul 25, 2024 · 3 comments
Closed
Assignees
Labels
bug Something isn't working

Comments

@ronaldtse
Copy link
Contributor

From:

To reproduce:

  • Checkout the branch pdf-latex-validation-report-attachments
  • Run: bundle exec metanorma sources/report-pdf-latex-validation/document.adoc

There are two issues:

  1. The attachments code expects the declared attachments path to start from PWD, instead of the document root (sources/report-pdf-latex-validation), or the local file root (sources/report-pdf-latex-validation/10303-49/)
  2. The attachment process fails:
<internal:pack>:29:in `unpack1'
ruby/3.3.0/base64.rb:298:in `strict_decode64'
ruby/gems/3.3.0/gems/isodoc-2.10.6/lib/isodoc/presentation_function/metadata.rb:27:in `block in save_attachment'
ruby/gems/3.3.0/gems/isodoc-2.10.6/lib/isodoc/presentation_function/metadata.rb:27:in `open'
ruby/gems/3.3.0/gems/isodoc-2.10.6/lib/isodoc/presentation_function/metadata.rb:27:in `save_attachment'
ruby/gems/3.3.0/gems/isodoc-2.10.6/lib/isodoc/presentation_function/metadata.rb:20:in `block in attachments_extract'
ruby/gems/3.3.0/gems/nokogiri-1.16.6-arm64-darwin/lib/nokogiri/xml/node_set.rb:235:in `block in each'
ruby/gems/3.3.0/gems/nokogiri-1.16.6-arm64-darwin/lib/nokogiri/xml/node_set.rb:234:in `upto'
ruby/gems/3.3.0/gems/nokogiri-1.16.6-arm64-darwin/lib/nokogiri/xml/node_set.rb:234:in `each'
ruby/gems/3.3.0/gems/isodoc-2.10.6/lib/isodoc/presentation_function/metadata.rb:19:in `attachments_extract'
ruby/gems/3.3.0/gems/isodoc-2.10.6/lib/isodoc/presentation_function/metadata.rb:6:in `metadata'
ruby/gems/3.3.0/gems/isodoc-2.10.6/lib/isodoc/presentation_xml_convert.rb:42:in `conversions'
ruby/gems/3.3.0/gems/isodoc-2.10.6/lib/isodoc/presentation_xml_convert.rb:28:in `convert1'
ruby/gems/3.3.0/gems/metanorma-iso-2.8.1/lib/isodoc/iso/presentation_xml_convert.rb:23:in `convert1'
ruby/gems/3.3.0/gems/isodoc-2.10.6/lib/isodoc/convert.rb:168:in `convert'
ruby/gems/3.3.0/gems/metanorma-iso-2.8.1/lib/metanorma/iso/processor.rb:69:in `output'
ruby/gems/3.3.0/gems/metanorma-2.0.3/lib/metanorma/compile/compile.rb:184:in `process_output_unthreaded'
ruby/gems/3.3.0/gems/metanorma-2.0.3/lib/metanorma/compile/compile.rb:170:in `process_exts1'
ruby/gems/3.3.0/gems/metanorma-2.0.3/lib/metanorma/compile/compile.rb:143:in `process_ext'
ruby/gems/3.3.0/gems/metanorma-2.0.3/lib/metanorma/compile/compile.rb:125:in `block in process_exts_run'
ruby/gems/3.3.0/gems/metanorma-2.0.3/lib/metanorma/compile/compile.rb:124:in `each'
ruby/gems/3.3.0/gems/metanorma-2.0.3/lib/metanorma/compile/compile.rb:124:in `process_exts_run'
ruby/gems/3.3.0/gems/metanorma-2.0.3/lib/metanorma/compile/compile.rb:119:in `process_exts'
@ronaldtse ronaldtse added the bug Something isn't working label Jul 25, 2024
@github-project-automation github-project-automation bot moved this to 🆕 New in Metanorma Jul 25, 2024
@ronaldtse ronaldtse moved this from 🆕 New to 🌋 Urgent in Metanorma Jul 25, 2024
@opoudjis
Copy link
Contributor

The attachments code expects the declared attachments path to start from PWD, instead of the document root (sources/report-pdf-latex-validation), or the local file root (sources/report-pdf-latex-validation/10303-49/)

Images are postprocessed to be relative to the document root. Doing the same for attachments.

@opoudjis
Copy link
Contributor

I'm seeing that the absolute links are happening after all, if the document is compiled in a document outside the PWD. Ugh. Fighting against Asciidoctor is a recurring waste of resources. Will convert the link to a relative link.

opoudjis added a commit that referenced this issue Jul 25, 2024
…working directory; use document location when opening attachment to convert it to DataURI: #898
@opoudjis
Copy link
Contributor

The attachment string, unlike Data URIs, was not being prevented from Sterile string substitution, in this case 53x5 => 53×5̩ (times symbol). Ouch. There is code to prevent smart formatting explicitly in data blocks, but I'd neglected to add attachment to presentation-metadata and semantic-metadata; I'm just going to prevent all smart formatting in metanorma-extension.

@github-project-automation github-project-automation bot moved this from 🌋 Urgent to ✅ Done in Metanorma Jul 25, 2024
@opoudjis opoudjis reopened this Jul 25, 2024
@github-project-automation github-project-automation bot moved this from ✅ Done to 🏗 In progress in Metanorma Jul 25, 2024
opoudjis added a commit that referenced this issue Jul 25, 2024
…working directory; use document location when opening attachment to convert it to DataURI: #898
@opoudjis opoudjis moved this from 🏗 In progress to On hold in Metanorma Jul 26, 2024
@github-project-automation github-project-automation bot moved this from On hold to ✅ Done in Metanorma Jul 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Done
Development

No branches or pull requests

2 participants