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

Posted by guidog on
URL: https://discuss.asciidoctor.org/Unable-to-call-to-remove-sub-within-Table-Cell-because-subs-is-frozen-tp8264.html

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