# Creates persistent ParseFunc setup for non-HTML content.
lib.parseFunc {
  makelinks = 1
  makelinks {
    http {
      keep = path
      extTarget = _blank
    }
    mailto {
      keep = path
    }
  }
  tags {
    a = USER
    a.userFunc = Centor\Site\UserFunc\ParseFunc->renderRteLink
  }
  allowTags = *,iconify-icon
  nonTypoTagStdWrap {
    HTMLparser = 1
    HTMLparser {
      keepNonMatchedTags = 1
      htmlSpecialChars = 2
    }
  }
}


# Creates persistent ParseFunc setup for RTE content (which is mainly HTML) based on the "default" transformation.
lib.parseFunc_RTE < lib.parseFunc
lib.parseFunc_RTE {
  # Processing <ol>, <ul> and <table> blocks separately
  externalBlocks = article, aside, blockquote, div, dd, dl, footer, header, nav, ol, section, table, ul, pre, figure, figcaption
  externalBlocks {
    ol {
      stripNL = 1
      stdWrap.parseFunc = < lib.parseFunc
    }
    ul {
      stripNL = 1
      stdWrap.parseFunc = < lib.parseFunc
    }
    pre {
      stdWrap.parseFunc < lib.parseFunc
    }
    table {
      stripNL = 1
      stdWrap {
        HTMLparser = 1
        HTMLparser {
          tags.table.fixAttrib.class {
            default = contenttable
            always = 1
            list = contenttable, rte-table-blank
          }
          keepNonMatchedTags = 1
        }
      }
      HTMLtableCells = 1
      HTMLtableCells {
        # Recursive call to self but without wrapping non-wrapped cell content
        default.stdWrap {
          parseFunc = < lib.parseFunc_RTE
          parseFunc.nonTypoTagStdWrap.encapsLines {
            nonWrappedTag =
            innerStdWrap_all.ifBlank =
          }
        }
        addChr10BetweenParagraphs = 1
      }
    }
    div {
      stripNL = 1
      callRecursive = 1
    }
    article < .div
    aside < .div
    figure {
      stripNL = 1
      stdWrap.wrap = <div class="figure-wrapper">|</div>
    }
    figcaption {
      stripNL = 1
    }
    blockquote < .div
    footer < .div
    header < .div
    nav < .div
    section < .div
    dl < .div
    dd < .div
  }
  nonTypoTagStdWrap {
    HTMLparser = 1
    HTMLparser {
      keepNonMatchedTags = 1
      htmlSpecialChars = 2
    }
    encapsLines {
      encapsTagList = p,pre,h1,h2,h3,h4,h5,h6,hr,dt
      remapTag.DIV = P
      nonWrappedTag = P
      innerStdWrap_all.ifBlank = &nbsp;
    }
  }
}
