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

Add document attributes for cover and back page image #227

Closed
Intelligent2013 opened this issue Oct 20, 2024 · 16 comments
Closed

Add document attributes for cover and back page image #227

Intelligent2013 opened this issue Oct 20, 2024 · 16 comments
Assignees
Labels
enhancement New feature or request

Comments

@Intelligent2013
Copy link
Contributor

Source issue: #226

Add parameters:

  • :coverpage-image: - image location, for image to be included on the PDF cover page. Image location is relative to the source document.
  • :backpage-image: - same, for image to be included on the PDF back page.

See similar parameters in https://www.metanorma.org/author/bsi/ref/document-attributes/.

Currently I think don't need to support comma-delimited list images, one image is enough.

@Intelligent2013
Copy link
Contributor Author

The document JIS Z 8301 for testing purposes: https://github.com/metanorma/mn-samples-jis/pull/48

:coverpage-image: images/coverpage.pdf
:backpage-image: images/backpage.pdf

@opoudjis
Copy link
Contributor

Coverpage images have been implemented for BSI, ITU, and Plateau. Rather than implement them separately for JIS, I am going to implement them across Metanorma.

  • BSI has node attribute coverpage-image, innercoverpage-image, tocside-image, backpage-image, with comma-delimited image files. It ultimately inserts them in Presentation Metadata under those names. (It initially inserts them in bibdata/ext, presumably to force Data URI encoding if expected: the Metanorma Extension element is normally off-limits to normalisation.)
  • ITU ony has coverpage-image, and does the same.
  • Plateau only has coverpage-image, and does the same.

So the solution I'm going to generalise to all of Metanorma is that of BSI, which encompasses the rest.

opoudjis added a commit to metanorma/metanorma.org that referenced this issue Oct 25, 2024
opoudjis added a commit to metanorma/metanorma-standoc that referenced this issue Oct 25, 2024
@opoudjis
Copy link
Contributor

opoudjis commented Oct 25, 2024

Because this is refactoring some code, @Intelligent2013, you'll need to pull standoc, iso, and jis. I'm pushing to main and breaking it, because release is Monday.

opoudjis added a commit to metanorma/metanorma-plateau that referenced this issue Oct 25, 2024
opoudjis added a commit to metanorma/metanorma-itu that referenced this issue Oct 25, 2024
@opoudjis opoudjis moved this from 🏗 In progress to 👀 In review in Metanorma Oct 25, 2024
@opoudjis
Copy link
Contributor

@Intelligent2013 Please confirm this is working.

@opoudjis
Copy link
Contributor

Remove cover images from relaton grammars, they are only temporarily put there, and end up instead in metanorma-extension.

opoudjis added a commit to relaton/relaton-model-bsi that referenced this issue Oct 25, 2024
opoudjis added a commit to relaton/relaton-model-plateau that referenced this issue Oct 25, 2024
@Intelligent2013
Copy link
Contributor Author

@Intelligent2013 Please confirm this is working.

@opoudjis unfortunately in the generated presentation XML there aren't element coverpage-image and backpage-image.

The document: https://github.com/metanorma/mn-samples-jis/pull/48 (branch: vertical_layout_8301)

bundle exec metanorma -t jis -x presentation document_vertical.adoc

Gemfile:

source "https://rubygems.org"

gem "metanorma-cli"
gem "metanorma-jis", git: "https://github.com/metanorma/metanorma-jis", branch: "main"
gem "metanorma-iso", git: "https://github.com/metanorma/metanorma-iso", branch: "main"
gem "metanorma-standoc", git: "https://github.com/metanorma/metanorma-standoc", branch: "main"

Gemfile.lock:

GIT
  remote: https://github.com/metanorma/metanorma-iso
  revision: b7642abbf5c9c05964ad4a5db800e87afc7c4555
  branch: main
  specs:
    metanorma-iso (2.8.8)
      metanorma-standoc (~> 2.9.3)
      mnconvert (~> 1.14)
      pubid
      tokenizer (~> 0.3.0)

GIT
  remote: https://github.com/metanorma/metanorma-jis
  revision: 14f639698bdc1c77b2854e053ee1eecdc0d9e8d9
  branch: main
  specs:
    metanorma-jis (0.3.6)
      japanese_calendar (~> 0)
      metanorma-iso (~> 2.8.0)
      pubid

GIT
  remote: https://github.com/metanorma/metanorma-standoc
  revision: 3ca4c40f67669134c0cfe8a5917f4351d8d77f90
  branch: main
  specs:
    metanorma-standoc (2.9.9)
      addressable (~> 2.8.0)
      asciidoctor (~> 2.0.0)
      asciimath2unitsml (~> 0.4.0)
      concurrent-ruby
      crass (~> 1.0.0)
      iev (~> 0.3.0)
      isodoc (~> 2.11.0)
      metanorma (>= 1.6.0)
      metanorma-plugin-datastruct (~> 0.3.0)
      metanorma-plugin-glossarist (~> 0.2.0)
      metanorma-plugin-lutaml (~> 0.7.0)
      metanorma-utils (~> 1.10.0)
      pngcheck
      relaton-cli (~> 1.19.0)
      relaton-iev (~> 1.2.0)
      ruby-jing
      unicode2latex (~> 0.0.1)
...

@ReesePlews
Copy link

ReesePlews commented Oct 26, 2024

Coverpage images have been implemented for BSI, ITU, and Plateau. Rather than implement them separately for JIS, I am going to implement them across Metanorma.

BSI has node attribute coverpage-image, innercoverpage-image, tocside-image, backpage-image, with comma-delimited image files. It ultimately inserts them in Presentation Metadata under those names. (It initially inserts them in bibdata/ext, presumably to force Data URI encoding if expected: the Metanorma Extension element is normally off-limits to normalisation.)

ITU ony has coverpage-image, and does the same.
Plateau only has coverpage-image, and does the same.
So the solution I'm going to generalise to all of Metanorma is that of BSI, which encompasses the rest.

hello @opoudjis i noticed in the discussion above "coverpage" and "Plateau" here; a quick question: is there, or could there be, control over the fonts designated for use in the cover page, if they were different than what are used in the body of the document? see rp/ribose_discussions#19

@ronaldtse
Copy link

@ReesePlews cover-page images are "per-document" settings where the font is a "per-flavor" setting.

The font used on a flavor's coverpage is currently determined by code. It is understandable that the font on different documents of the same flavor are the same for consistency reasons.

@opoudjis
Copy link
Contributor

@Intelligent2013 It's working fine, but you need to also include

gem "isodoc", git: "https://github.com/metanorma/isodoc", branch: "features/xref-counter-classes"

So:

<presentation-metadata><name>coverpage-image</name><value><image src="data:...

I have been forced to remove Noto JP fonts, which were crashing compilation.

@opoudjis opoudjis moved this from 🏗 In progress to 👀 In review in Metanorma Oct 26, 2024
@Intelligent2013
Copy link
Contributor Author

gem "isodoc", git: "https://github.com/metanorma/isodoc", branch: "features/xref-counter-classes"

@opoudjis no effect.

My Gemfile.lock:

GIT
  remote: https://github.com/metanorma/isodoc
  revision: c247444567753642c49b8bdbeecf80aca995674d
  branch: features/xref-counter-classes
  specs:
    isodoc (2.11.4)
      base64
      bigdecimal
      html2doc (~> 1.8.1)
      mn-requirements (~> 0.4.0)
      mn2pdf
      relaton-render (~> 0.7.1)
      roman-numerals
      rouge (~> 4.0)
      thread_safe
      twitter_cldr (>= 6.6.0)
      uuidtools

GIT
  remote: https://github.com/metanorma/metanorma-iso
  revision: b7642abbf5c9c05964ad4a5db800e87afc7c4555
  branch: main
  specs:
    metanorma-iso (2.8.8)
      metanorma-standoc (~> 2.9.3)
      mnconvert (~> 1.14)
      pubid
      tokenizer (~> 0.3.0)

GIT
  remote: https://github.com/metanorma/metanorma-jis
  revision: e09e6683a0b12116c39d1c3d2ba5265c06d6ef8d
  branch: main
  specs:
    metanorma-jis (0.3.6)
      japanese_calendar (~> 0)
      metanorma-iso (~> 2.8.0)
      pubid

GIT
  remote: https://github.com/metanorma/metanorma-standoc
  revision: 3ca4c40f67669134c0cfe8a5917f4351d8d77f90
  branch: main
  specs:
    metanorma-standoc (2.9.9)
      addressable (~> 2.8.0)
      asciidoctor (~> 2.0.0)
      asciimath2unitsml (~> 0.4.0)
      concurrent-ruby
      crass (~> 1.0.0)
      iev (~> 0.3.0)
      isodoc (~> 2.11.0)
      metanorma (>= 1.6.0)
      metanorma-plugin-datastruct (~> 0.3.0)
      metanorma-plugin-glossarist (~> 0.2.0)
      metanorma-plugin-lutaml (~> 0.7.0)
      metanorma-utils (~> 1.10.0)
      pngcheck
      relaton-cli (~> 1.19.0)
      relaton-iev (~> 1.2.0)
      ruby-jing
      unicode2latex (~> 0.0.1)

Well, looks like something wrong in my environment or Metanorma installation. I've tried to generate the PDF and displayed mn2pdf command line contains metanorma-jis-0.3.6, but not metanorma-jis-e09e6683a0b1 (i.e. without last commit id):
java -Xss10m -Xmx3g -Djava.awt.headless=true -Duser.home=C:/Users/TestUser -jar C:/Users/TestUser/AppData/Local/Temp/aib552D.tmp/lib/ruby/gems/3.1.0/gems/mn2pdf-1.99/bin/mn2pdf.jar --xml-file "C:/Users/TestUser/AppData/Local/Temp/test20241026-17508-6rw7v.xml" --xsl-file "C:/Users/TestUser/AppData/Local/Temp/aib552D.tmp/lib/ruby/gems/3.1.0/gems/metanorma-jis-0.3.6/lib/isodoc/jis/jis.international-standard.xsl" --pdf-file "D:/Work/Metanorma/repositories/mn-samples-jis/sources/jis-z-8301-2019/test.pdf" --param baseassetpath="D:/Work/Metanorma/repositories/mn-samples-jis/sources/jis-z-8301-2019" --syntax-highlight --font-manifest "C:/Users/TestUser/AppData/Local/Temp/fontist_locations20241026-17508-nnbbj4.yml"

I have been forced to remove Noto JP fonts, which were crashing compilation.

It may occurs due the old jis xslt. I didn't merge it yet.

@Intelligent2013
Copy link
Contributor Author

I understood the problem. But not the solution.

There are two metanorms-jis (and another gems) versions:

  • in the 100Mb file C:\ProgramData\chocolatey\lib\metanorma\tools\metanorma.exe - installed via Chocolatey by choco install metanorma -y
  • in the folder C:\tools\ruby31\lib\ruby\gems\3.1.0\bundler\gems\metanorma-jis-e09e6683a0b1 - installed by running bundle update in the folder mn-samples-jis with modified Gemfile (see post above)

bundle info metanorma-jis outputs:

 * metanorma-jis (0.3.6 e09e668)
        Summary: metanorma-jis lets you write JIS standards in AsciiDoc.
        Homepage: https://github.com/metanorma/metanorma-jis
        Path: C:/tools/ruby31/lib/ruby/gems/3.1.0/bundler/gems/metanorma-jis-e09e6683a0b1
        Reverse Dependencies:
                metanorma-cli (1.10.10) depends on metanorma-jis (~> 0.3.0)
                metanorma-plateau (0.1.8) depends on metanorma-jis (~> 0.3.0)

When I run bundle exec metanorma -t jis -x presentation document_vertical.adoc, the metanorma.exe unpacks all own content into the temp folder C:/Users/TestUser/AppData/Local/Temp/aib552D.tmp/lib/ruby/gems/3.1.0/gems/, but the folder C:\tools\ruby31\lib\ruby\gems\3.1.0\bundler\gems doesn't using at all. I.e. all gems are using from the two week ago release metanorma.exe.
ruby -version: ruby 3.1.3p185 (2022-11-24 revision 1a6b16756e) [x64-mingw-ucrt]
bundler --version: Bundler version 2.3.26.

@ronaldtse
Copy link

@Intelligent2013 this means the "bundle exec metanorma" command is using the wrong metanorma executable. It should use the bundled version instead of the choco version. This seems like a PATH problem?

Ping @CAMOBAP @maxirmx

@CAMOBAP
Copy link
Contributor

CAMOBAP commented Oct 27, 2024

This seems like a PATH problem?

@ronaldtse @Intelligent2013 looks the same to me, it looks like the chocolatey's bin is appeared before gem's bin for some reason

One of the solutions is to call metanorma by a full path c:\Ruby3.1\..., or if you have cloned metanorma-cli you may call bundle exec exe/metanorma ...

@Intelligent2013
Copy link
Contributor Author

@ronaldtse @CAMOBAP you are right.
where metanorma outputs:

C:\ProgramData\chocolatey\bin\metanorma.exe
C:\tools\ruby31\bin\metanorma
C:\tools\ruby31\bin\metanorma.bat
C:\Users\TestUser\AppData\Local\Microsoft\WindowsApps\metanorma
C:\Users\TestUser\AppData\Local\Microsoft\WindowsApps\metanorma.bat

The path C:\ProgramData\chocolatey\bin\ declared in the 'system' environment variables list, but the path C:\tools\ruby31\bin\ in the 'user' variables list. I've installed Chocolatey a year ago, may be via the admin rights.
I've moved C:\ProgramData\chocolatey\bin\ into the and of user variables list and the problem was gone.

Thank you!

@github-project-automation github-project-automation bot moved this from 👀 In review to ✅ Done in Metanorma Oct 27, 2024
@Intelligent2013
Copy link
Contributor Author

@opoudjis sorry, looks like I've closed your ticket.

@github-project-automation github-project-automation bot moved this from ✅ Done to 🏗 In progress in Metanorma Oct 27, 2024
@Intelligent2013 Intelligent2013 moved this from 🏗 In progress to 👀 In review in Metanorma Oct 27, 2024
@opoudjis
Copy link
Contributor

No, it was for you to close, you've confirmed it's now working as expected.

@github-project-automation github-project-automation bot moved this from 👀 In review to ✅ Done in Metanorma Oct 27, 2024
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

5 participants