Unable to call to remove_sub within Table::Cell because @subs is frozen

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Unable to call to remove_sub within Table::Cell because @subs is frozen

guidog
Hi,

   I am making a process to read the Abstract Syntax Tree of AsciiDoc and generate the same file but translated.

When the process reached a leaf of the tree I want to be able to prevent implicit substitutions

In general I can do that using the remove_subs method of each AbstractNode

  block.remove_sub 'quotes'.to_sym
  block.remove_sub 'specialcharacters'.to_sym
  block.remove_sub 'macros'.to_sym
  block.remove_sub 'replacements'.to_sym
  block.remove_sub 'post_replacements'.to_sym

But there is a situation where I can't do that, when the block is a simple cell (| ** text **) because the @subs variable is frozen.

Looking at the code I found that the problem is related to the following line  (@subs = NORMAL_SUBS)

    https://github.com/asciidoctor/asciidoctor/blob/master/lib/asciidoctor/table.rb#L313

I also saw that in list.rb the code uses another way to do it

   @subs = NORMAL_SUBS.drop 0   instead of @subs = NORMAL_SUBS

Is there a workaround to avoid substitutions in the Table::Cell blocks?

Thanks
guido
Reply | Threaded
Open this post in threaded view
|

Re: Unable to call to remove_sub within Table::Cell because @subs is frozen

guidog
Hi,

     I found that source method can access to @text without substitutions.

  def text
    apply_subs @text, @subs
  end

  def source
    @text
  end

There are different ways to access to 'text' in each AbstractNode:
  - text
  - source
  - content
  - lines

I didn't see 'source' getter in Table::Cell.

Sorry for the inconvenience.

Regards
guido