jirutka / asciidoctor-html5s

Semantic HTML5 converter (backend) for Asciidoctor
MIT License
89 stars 10 forks source link

-> replaces to -> in code blocks #4

Closed DavidGamba closed 6 years ago

DavidGamba commented 6 years ago

When doing something like:

----
a -> b 
----

It replaces to:

<div class="listing-block"><pre>a -&gt; b</pre></div>

Instead of keeping things verbatim. According to https://asciidoctor.org/docs/user-manual/#attributes-2 They shouldn't be substituted.

jirutka commented 6 years ago

> is a special character (in HTML), these are substituted by a corresponding character entity in all contexts except pass macro and pass block (see table Substitution groups). Otherwise it would result in invalid HTML. The built-in HTML converter in Asciidoctor behaves the same.

DavidGamba commented 5 years ago

@jirutka I am using this backend to generate confluence XHTML output. Do you know if there is a way to disable the HTML substitutions for the code blocks only? If I apply the subs=none at the source then it applies to all backends.

jirutka commented 5 years ago
[source, subs=none]
----
<b>bold</b>
----
DavidGamba commented 5 years ago

@jirutka That is exacly what I am doing:

[source, subs={code_subs}]
----
<b>bold</b>
----

Then, when building:

# For confluence:
$ asciidoctor -r asciidoctor-html5s -b html5s -a htmlsyntax=xml -a code_subs=none ...
# For html:
$ asciidoctor -a code_subs=normal ...

But I am littering my code with: subs={code_subs} everywhere, and was hoping I could just disable that on the backend itself.

DavidGamba commented 5 years ago

I was able to accomplish this with a treeprocessor:

  class RemoveListingSubsTreeprocessor < ::Asciidoctor::Extensions::Treeprocessor
    def process(document)
      document.find_by(context: :listing) do |block|
        block.subs.clear
      end
    end
  end

Thanks for the great project!