Space in markup being ignored
As a result of the refactoring being done in this gem,
<html>
<body><p>The attribute "uniformResourceIdentifier"<i> </i>takes</p></body>
</html>
is being incorrectly converted to:
The attribute "uniformResourceIdentifier"takes
This is breaking the tests in metanorma-plugin-lutaml, as found in https://github.com/metanorma/metanorma-plugin-lutaml/issues/107
As I have stated in that ticket, there are downstream impacts to radical changes to gems such as what is being done in https://github.com/metanorma/reverse_adoc/issues/84 , and whoever is doing that work is responsible for testing for those downstream impacts. This code should NOT have been released to production without such testing, and I will not accept the update into the Metanorma code stack until that testing has been done. I have already had to issue one hotfix because of this gem's assumption that it is being passed mutable strings.
Here's the culprit:
lib/reverse_adoc/converters/em.rb
module ReverseAdoc
module Converters
class Em < Base
def to_coradoc(node, state = {})
content = treat_children_coradoc(node,
state.merge(already_italic: true))
if Coradoc::Generator.gen_adoc(content).strip.empty?
return ""
end
Wrong. And it is not what I had:
module ReverseAdoc
module Converters
class Em < Base
def convert(node, state = {})
content = treat_children(node, state.merge(already_italic: true))
if content.strip.empty? || state[:already_italic]
content
else
"#{content[/^\s*/]}_#{content.strip}_#{content[/\s*$/]}"
end
end
end
If I see <em> </em>, I am going to return " ", not "".
Presumably you did this for a reason, but this needs to be fixed, including consideration of whatever downstream reasons you had for introducing this change in logic. Until it is fixed, however, reverse_adoc v1.0.x is not going to be accepted in the Metanorma stack.
FYI This bug is supposed to be fixed in Coradoc, not in reverse_adoc.
I DID TEST IT WITH CORADOC
index a08ad72..5b996d7 100644
--- a/lib/metanorma/plugin/lutaml/liquid/custom_filters.rb
+++ b/lib/metanorma/plugin/lutaml/liquid/custom_filters.rb
@@ -1,4 +1,4 @@
-require "reverse_adoc"
+require "coradoc/reverse_adoc"
module Metanorma
module Plugin
diff --git a/metanorma-plugin-lutaml.gemspec b/metanorma-plugin-lutaml.gemspec
index afc13c2..22961e3 100644
--- a/metanorma-plugin-lutaml.gemspec
+++ b/metanorma-plugin-lutaml.gemspec
@@ -30,7 +30,8 @@ Gem::Specification.new do |spec|
spec.add_dependency "liquid"
spec.add_dependency "lutaml"
spec.add_dependency "relaton-cli"
- spec.add_dependency "reverse_adoc", "~> 0.3.7"
+# spec.add_dependency "reverse_adoc", "~> 0.3.7"
+ spec.add_dependency "coradoc"
spec.add_development_dependency "debug"
spec.add_development_dependency "equivalent-xml"
The result is
<p id="_">Liquid error: internal</p>
EVERYWHERE.
This would not be such an issue if it were not for the unwelcome warning:
Deprecated: reverse_adoc has been merged into coradoc gem.
| Please update your references from:
| require 'reverse_adoc'
| To:
| require 'coradoc/reverse_adoc'
|
| You are referencing an old require here:
Which is now appearing whenever Metanorma is executed. You do not get to issue warnings to our users forcing me to upgrade to coradoc, when coradoc IS STILL BROKEN for this use case, WHICH I EXPLICITLY IDENTIFIED.
RETRACT THIS WARNING IMMEDIATELY, OR DEBUG THIS ISSUE.
It works with Coradoc, and I've added instructions to the README on the migration too.
irb(main):006:0' string = '<html>
irb(main):007:0' <body><p>The attribute "uniformResourceIdentifier"<i> </i>takes</p></body>
irb(main):008:0' </html>
irb(main):009:0> '
=> "<html>\n <body><p>The attribute \"uniformResourceIdentifier\"<i> </i>takes</p></body>\n</html>\n"
irb(main):010:0> require 'coradoc/reverse_adoc'
=> true
irb(main):011:0> Coradoc::ReverseAdoc.convert(string)
=> "The attribute \"uniformResourceIdentifier\" takes\n\n"
irb(main):012:0>