zf

zenflows testing
git clone https://s.sonu.ch/~srfsh/zf.git
Log | Files | Refs | Submodules | README | LICENSE

html_renderer.ex (941B)


      1 defmodule EarmarkParser.Ast.Renderer.HtmlRenderer do
      2 
      3   import EarmarkParser.Context, only: [prepend: 2]
      4   import EarmarkParser.Helpers.HtmlParser
      5   import EarmarkParser.Helpers.AstHelpers, only: [annotate: 2]
      6 
      7   @moduledoc false
      8 
      9   # Structural Renderer for html blocks
     10   def render_html_block(lines, context, annotation)
     11   def render_html_block(lines, context, annotation) do
     12     [tag] = parse_html(lines)
     13     tag_ = if annotation, do: annotate(tag, annotation), else: tag
     14     prepend(context, tag_)
     15   end
     16 
     17   def render_html_oneline([line|_], context, annotation \\ []) do
     18     [tag|rest] = parse_html([line])
     19     tag_ = if annotation, do: annotate(tag, annotation), else: tag
     20     prepend(context, [tag_|rest])
     21   end
     22   
     23   @html_comment_start ~r{\A\s*<!--}
     24   @html_comment_end ~r{-->.*\z}
     25   def render_html_comment_line(line) do
     26     line
     27     |> String.replace(@html_comment_start, "")
     28     |> String.replace(@html_comment_end, "")
     29   end
     30 
     31 end