metanorma / coradoc

Coradoc is the Core AsciiDoc Parser used by Metanorma
MIT License
1 stars 2 forks source link

reverse_adoc: Correct syntax for levels >= 6 #76

Closed hmdne closed 4 months ago

hmdne commented 4 months ago

This fixes #69 and fixes #66. This does fix NOT #65.

Excerpts from a diff of our incoming document (please don't miss my comment for the second excerpt):

diff -Naur _prev/sections/section-09.adoc _curr/sections/section-09.adoc
--- _prev/sections/section-09.adoc      2024-05-30 23:39:22.776664086 +0200
+++ _curr/sections/section-09.adoc      2024-05-30 23:38:59.504662193 +0200
@@ -154,7 +154,7 @@
 [[toc9_06_02]]
 ====  ファイル単位

-===== (1) ファイル単位
+=====  ファイル単位

 ファイル単位は、「作業規程の準則 付録7 公共測量標準図式 第84条」において定められた国土基本図の図郭とする。 +
 また、一つのファイルには、同一の空間参照系のオブジェクトのみを含む。 +
@@ -162,7 +162,7 @@

  

-===== (2) ファイルサイズとファイル分割
+=====  ファイルサイズとファイル分割

 1ファイルのデータ量の上限は最大1GBとする。 +
 1ファイルのデータ量が1GBを超える場合は、ファイルを分割する。分割したファイルは、同じ図郭を重複して含んではならない。
@@ -180,7 +180,7 @@
 [[toc9_06_03]]
 ====  境界線上の地物の取り扱い

-===== (1) ファイルの境界線上に存在する地物
+=====  ファイルの境界線上に存在する地物

 ファイル単位となる国土基本図の図郭の境界線上に存在する地物は分割しない。 +
 複数の図郭に跨って存在する地物は、それぞれの図郭に平面投影した形状が含まれる面積又は延長の割合を算出し、この割合が最も大きい図郭に対応するファイルに含む。 +
@@ -189,7 +189,7 @@

  

-===== (2) 行政区域の境界線上に存在する地物
+=====  行政区域の境界線上に存在する地物

  データセットの単位となる行政区域の境界線に跨って存在する地物は、分割しない。

@@ -282,7 +282,8 @@

 image::images/461.webp["","",""]

-===== 1) core:ImplicitGeometry
+[level=5]
+=====  core:ImplicitGeometry

 [cols="1,1,2"]
 |===
@@ -302,7 +303,8 @@

 |===

-===== 2) core:TransformationMatrix4x4
+[level=5]
+=====  core:TransformationMatrix4x4

 [cols="1,1,2"]
 |===
@@ -316,7 +318,8 @@

 |===

-===== 3) ImplicitGeometry_mimeType.xml
+[level=5]
+=====  ImplicitGeometry_mimeType.xml

 [cols=2]
 |===
@@ -331,7 +334,8 @@

 |===

-===== 4) ImplicitGeometryにより地下埋設物の形状を表現する場合の関連役割
+[level=5]
+=====  ImplicitGeometryにより地下埋設物の形状を表現する場合の関連役割

 地下埋設物の形状を、ImplicitGeometryにより表現する場合、frn:CityFurnitureから継承する関連役割を使用する。

Here, we have some issue. Some level 4 paragraph has no number. I'm adding a comment FIXME for editor to correct.

diff -Naur _prev/sections/section-07.adoc _curr/sections/section-07.adoc
--- _prev/sections/section-07.adoc      2024-05-30 23:39:22.776664086 +0200
+++ _curr/sections/section-07.adoc      2024-05-30 23:38:59.504662193 +0200
@@ -22,7 +22,9 @@

  

-===== (1) 符号化要件
+=====  符号化要件
+
+// FIXME

 ===== 【符号化の対象とする応用スキーマとスキーマ言語】

@@ -31,6 +33,8 @@

  

+// FIXME
+
 ===== 【使用する文字レパートリ】

 [none]
@@ -40,6 +44,8 @@

  

+// FIXME
+
 ===== 【データ集合とオブジェクトの識別】

 [none]
@@ -51,21 +57,21 @@

  

-===== (2) 入力データ構造
+=====  入力データ構造

 [none]
 **  入力データ構造は、応用スキーマクラス図と実装される個々のインスタンスとの関係を示すものである。入力データ構造は、CityGMLが参照するGML[3]において定義される Annex F GML-to-UML Application Schema Encoding Rulesに従う。 

  

-===== (3) 出力データ構造
+=====  出力データ構造

 [none]
 **  出力データ構造には、i-UR 3.0及びCityGML 2.0を使用する。拡張子は、「.gml」とする。

  

-===== (4) 変換規則
+=====  変換規則

 [none]
 ** 1) スキーマ変換規則

Metanorma PR checklist

ronaldtse commented 4 months ago

Here, we have some issue. Some level 4 paragraph has no number. I'm adding a comment FIXME for editor to correct.

This is very useful.

ronaldtse commented 4 months ago

Can we merge this?

hmdne commented 4 months ago

Please take a look at my comment on https://github.com/metanorma/coradoc/issues/69#issuecomment-2140888768

If that's good enough for you, then feel free to merge.

ronaldtse commented 4 months ago

If that's good enough for you, then feel free to merge.

Is this in line with Asciidoctor syntax? If so we can merge. Thanks.

hmdne commented 4 months ago

@ronaldtse I found no mention of [level] in AsciiDoc syntax. And AsciiDoctor itself doesn't support it. So, merging that would make HTML's H5 and H6 equivalent to H4 in non-extended implementations.

hmdne commented 4 months ago

@ronaldtse To be entirely clear, ====== is a correct syntax according to AsciiDoctor and their reference document. ======= is not. The first is compiled by AsciiDoctor into <h6> and is generated from <h5> in the current version of reverse_adoc. The second is generated from <h6> in the current version of reverse_adoc but is not accepted by AsciiDoctor. This PR would change both <h5> and <h6> into a new syntax:

[level=x]
===== something

Therefore it will now return correct AsciiDoc for <h6> encountered in document, but would break compatiblity with AsciiDoctor on <h5> (because it can't parse [level] property, so since this patch it would generate headings one level lower for this particular tag).

ronaldtse commented 4 months ago

@hmdne we want to be compatible with Asciidoctor, so h6 goes to 6 equal signs and vice versa. Thanks.

ronaldtse commented 4 months ago

I believe “level” is an Metanorma extension to support deeper clauses. The application of level is necessary for us to support users.

hmdne commented 4 months ago

So, I will amend this PR to handle levels>=6 ("<h7>"+ which doesn't exist with HTML, but let's say custom documents could generate it) as:

[level=7]
====== Title

And also to correct what I extracted from your comment into #79 . This would also handle the incoming document to generate at most ====== (level5) and generate no [level] clauses since it contains no levels higher than that.

ronaldtse commented 4 months ago

@hmdne agreed. Thanks.

ronaldtse commented 4 months ago

Usage of [level=*] in Metanorma is described here:

I've updated the code here (3a27873) to only add level beyond 6 equal signs.

@hmdne can you review and see if it's good to merge? I might be missing something.

hmdne commented 4 months ago

@ronaldtse LGTM