metanorma / metanorma-plugin-glossarist

Glossarist plugin for Metanorma
BSD 2-Clause "Simplified" License
1 stars 0 forks source link

feat: allow anchor-prifix in render tag #35

Open HassanAkbar opened 3 months ago

HassanAkbar commented 3 months ago

Added an option to allow anchor prefix when rendering a single concept or complete dataset as discussed here -> https://github.com/metanorma/metanorma-plugin-glossarist/issues/27#issuecomment-2275553450

fixes #27

HassanAkbar commented 3 months ago

@opoudjis Should I also sanitize the prefix and id to convert all forbidden characters to _, or is this enough for what you need?

opoudjis commented 3 months ago

@opoudjis Should I also sanitize the prefix and id to convert all forbidden characters to _, or is this enough for what you need?

It turns out that yes, you will need to do that sanitisation in the glossarist plugin. : inside of cross-references is already being used to do namespaced cross-references (which we've done for Express), so Metanorma ends up putting them inside of the bibliography, and treats their content after the first colon as an anchor within an external file. They simply will not work as is.

So yes, I will need you to escape : in identifiers-as-anchors, in both cross-references to identifiers, and anchors. The function to do so consistently is Metanorma::Utils.to_ncname()

opoudjis commented 3 months ago

@HassanAkbar Needs sanitisation in BOTH anchors and cross-references; so:

[[urn_iso_std_iso_14812_3.1.1.1]]
=== entity

concrete or abstract thing that exists, did exist, or can possibly exist, including associations among these things

[example]
{{urn:iso:std:iso:14812:3.1.1.6,person,Person}}, object, event, idea, process, etc.

needs to be:

[[urn_iso_std_iso_14812_3.1.1.1]]
=== entity

concrete or abstract thing that exists, did exist, or can possibly exist, including associations among these things

[example]
{{urn_iso_std_iso_14812_3.1.1.6,person,Person}}, object, event, idea, process, etc.

The anchor needs to look identical to the concept reference to the anchor (since anchors is what we are doing).

HassanAkbar commented 3 months ago

@HassanAkbar Needs sanitisation in BOTH anchors and cross-references;

@opoudjis I am currently working on making the references sanitized. I am identifying the places where the references can appear i.e notes, examples, definitions etc and then I will perform sanitization for all those places when loading the concept.

HassanAkbar commented 3 months ago

@opoudjis I've updated the PR to sanitize the references as well. I will test the regex on complete glossaries to see if it makes a significant difference or not and will update it accordingly but I think that this will fix the issue of anchors and references.

opoudjis commented 3 months ago

And crossreferences to anchors need to be formatted as anchor cross-references: {{<<urn_iso_std_iso_14812_3.1.4.7>>,physical view}}. {{urn_iso_std_iso_14812_3.1.4.7,physical view}} is interpreted as "term, rendered term" (so it is looking for a term titled urn_iso_std_iso_14812_3.1.4.7, but will display it as "physical view". Therefore it will not work.

The syntax is: {{ (<<anchor>>,)? term(, rendered term)?(, cross-reference number)?(, options)? }}: https://www.metanorma.org/author/topics/sections/concepts/#citeterms

opoudjis commented 3 months ago

And globally replacing {{urn([^,]+), with {{<<urn\1>>, in the generated asciidoc removes all the missing cross-reference warnings...

HassanAkbar commented 3 months ago

And globally replacing {{urn([^,]+), with {{<<urn\1>>, in the generated asciidoc removes all the missing cross-reference warnings...

@opoudjis I think this should be fixed in the data source because the prefix and ids can be different for different datasources. I will open a PR for this fix in the isotc204-glossary repo.

ronaldtse commented 3 months ago

@HassanAkbar there are two things we should do with glossarist.

  1. Change to use lutaml-model
  2. Use Coradoc to generate AsciiDoc.
opoudjis commented 1 month ago

@HassanAkbar Update on this please.