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

Coradoc::Input::HTML: Fix complex list items #143

Merged
merged 2 commits into from
Dec 14, 2024
Merged

Conversation

hmdne
Copy link
Contributor

@hmdne hmdne commented Dec 10, 2024

This commit fixes handling of complex list items.

Before Coradoc refactor, reverse_adoc used to treat all children of list elements as inline elements (if I recall correctly)

After Coradoc refactor, we treat all children of list elements as non-online elements (necessitating line break).

This broke certain assumptions we have while dealing with BIPM incoming documents. In particular, whenever there was a subscript involved, we get unexpected line breaks.

This PR aims to correctly handle all inline and non-inline list children, according to AsciiDoc specification[1].

Since this is quite a large refactor of a crucial part of documents, this may break a couple of assumptions, so I would really appreciate some testing before merging that.

[1] https://docs.asciidoctor.org/asciidoc/latest/lists/continuation/

@opoudjis @ronaldtse

Metanorma PR checklist

This commit fixes handling of complex list items.

Before Coradoc refactor, reverse_adoc used to treat all
children of list elements as inline elements (if I recall correctly)

After Coradoc refactor, we treat all children of list
elements as non-online elements (necessitating line break).

This broke certain assumptions we have while dealing with
BIPM incoming documents. In particular, whenever there was
a subscript involved, we get unexpected line breaks.

This PR aims to correctly handle all inline and non-inline
list children, according to AsciiDoc specification[1].

Since this is quite a large refactor of a crucial part of
documents, this may break a couple of assumptions, so
I would really appreciate some testing before merging that.

[1] https://docs.asciidoctor.org/asciidoc/latest/lists/continuation/
@hmdne
Copy link
Contributor Author

hmdne commented Dec 10, 2024

I noted an error while converting expressions like <ul><li> test <b>test</b> test</li> </ul> where separating whitespace is stripped. Will try to amend it shortly.

str.gsub(/\A[[:space:]]+|[[:space:]]+\z/, "")
def self.strip_unicode(str, only: nil)
str = str.gsub(/\A[[:space:]]+/, "") unless only == :end
str = str.gsub(/[[:space:]]+\z/, "") unless only == :begin

Check failure

Code scanning / CodeQL

Polynomial regular expression used on uncontrolled data High

This
regular expression
that depends on a
library input
may run slow on strings with many repetitions of ' '.
This
regular expression
that depends on a
library input
may run slow on strings with many repetitions of ' '.
This
regular expression
that depends on a
library input
may run slow on strings with many repetitions of ' '.
This
regular expression
that depends on a
library input
may run slow on strings with many repetitions of ' '.
This
regular expression
that depends on a
library input
may run slow on strings with many repetitions of ' '.
hmdne added a commit to metanorma/bipm-data-importer that referenced this pull request Dec 13, 2024
- use additional urls for finding more content
- use an experimental branch of Coradoc (metanorma/coradoc#143)
- fix numbering for CGPM so that produced diff will be smaller
- small fixes for parsing content

This fixes #49 and this fixes #50
hmdne added a commit to metanorma/bipm-data-importer that referenced this pull request Dec 13, 2024
- use additional urls for finding more content
- use an experimental branch of Coradoc (metanorma/coradoc#143)
- fix numbering for CGPM so that produced diff will be smaller
- small fixes for parsing content

This fixes #49 and this fixes #50
@ronaldtse ronaldtse merged commit a130362 into main Dec 14, 2024
14 of 16 checks passed
@ronaldtse ronaldtse deleted the hmdne/fix-complex-lists branch December 14, 2024 05:12
ronaldtse pushed a commit to metanorma/bipm-data-importer that referenced this pull request Dec 14, 2024
- use additional urls for finding more content
- use an experimental branch of Coradoc (metanorma/coradoc#143)
- fix numbering for CGPM so that produced diff will be smaller
- small fixes for parsing content

This fixes #49 and this fixes #50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants