<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://community.appian.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>markdowntosail function</title><link>https://community.appian.com/discussions/f/user-interface/18950/markdowntosail-function</link><description>Hi, 
 I am trying to convert HTML I receive from a web service in to rich text. 
 I have tried using the markdowntosail function found in Markdown to SAIL (v1.0.0) [com.appiancorp.ps.plugins.richtexttools] component and using it on 20.1 
 The purpose</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: markdowntosail function</title><link>https://community.appian.com/thread/80591?ContentTypeID=1</link><pubDate>Tue, 30 Mar 2021 14:09:29 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:c3d3fe92-2525-4fbb-8932-948100eb69fd</guid><dc:creator>Mike Schmitt</dc:creator><description>&lt;p&gt;I thought I&amp;#39;d ended up posting this somewhere but after this long I have no&amp;nbsp; idea... so i&amp;#39;ll attach it below:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="java"&gt;/* rule!GLBL_CMPT_RichTextHTMLPreview */
a!localVariables(
  local!formatBreakdown: rule!GLBL_UTIL_GetParsedRichTextBreakdown(htmlText: ri!htmlText),
  
  a!richTextDisplayField(
    label: ri!label,
    labelPosition: rule!GLBL_replaceNull(ri!labelPosition, &amp;quot;COLLAPSED&amp;quot;),
    instructions: ri!instructions,
    showWhen: ri!showWhen,
    value: {
      a!forEach(
        local!formatBreakdown,
        a!richTextItem(
          text:  rule!GLBL_UTIL_FormatHTMLLinebreaksForTextDisplay(
            htmlText: fv!item.row
          ),
          style: {
            fv!item.formats
          },
          link: a!safeLink(
            uri: fv!item.link,
            showWhen: not(rule!GLBL_isBlank(fv!item.link))
          )
        )
      )
    }
  )
)

/* rule!GLBL_UTIL_GetParsedRichTextBreakdown */
a!localVariables(
  local!formatChangeMarker: &amp;quot;[[[formatChange]]]&amp;quot;,

  local!test: regexreplaceall(
    pattern: &amp;quot;(&amp;lt;[biu]&amp;gt;|&amp;lt;a href=&amp;quot;&amp;quot;.+?&amp;quot;&amp;quot;|&amp;lt;/[biua]&amp;gt;)&amp;quot;,
    searchstring: ri!htmltext,
    replacementString: local!formatChangeMarker &amp;amp; &amp;quot;$1&amp;quot;
  ),
  local!array: split(local!test, local!formatChangeMarker),

  local!formatMarks: a!forEach(
    local!array,

    tostring(
      if(
        left(fv!item, 8) = &amp;quot;&amp;lt;a href=&amp;quot;,
        &amp;quot;a{{&amp;quot; &amp;amp; extract(fv!item, &amp;quot;&amp;lt;a href=&amp;quot;&amp;quot;&amp;quot;, &amp;quot;&amp;quot;&amp;quot;&amp;gt;&amp;quot;) &amp;amp; &amp;quot;}}&amp;quot;,
        extract(
          left(fv!item, 4),
          &amp;quot;&amp;lt;&amp;quot;,
          &amp;quot;&amp;gt;&amp;quot;
        )
      )
    )
  ),

  a!forEach(
    local!formatMarks,
    with(
      local!list: joinarray(index(local!formatMarks, enumerate(fv!index)+1), &amp;quot;;&amp;quot;),
      local!list1: regexreplaceall( &amp;quot;b(.+?)/b&amp;quot;, local!list, &amp;quot;$1&amp;quot;),
      local!list2: regexreplaceall( &amp;quot;i(.+?)/i&amp;quot;, local!list1, &amp;quot;$1&amp;quot;),
      local!list3: regexreplaceall( &amp;quot;u(.+?)/u&amp;quot;, local!list2, &amp;quot;$1&amp;quot;),
      local!list4: regexreplaceall( &amp;quot;a\{\{.+?\}\}(.+?)/a&amp;quot;, local!list3, &amp;quot;$1&amp;quot;),
      {
        row: regexreplaceall(&amp;quot;&amp;lt;[bui]&amp;gt;|&amp;lt;a href=&amp;quot;&amp;quot;.+?&amp;quot;&amp;quot;&amp;gt;|&amp;lt;/[buia]&amp;gt;&amp;quot;, local!array[fv!index], &amp;quot;&amp;quot;),
        formats: touniformstring(
          a!forEach(
            rule!GLBL_UTIL_removeBlankValuesFromArray( trim(split(local!list4, &amp;quot;;&amp;quot;)) ),
            if(
              fv!item = &amp;quot;i&amp;quot;,
              &amp;quot;EMPHASIS&amp;quot;,
              fv!item = &amp;quot;b&amp;quot;,
              &amp;quot;STRONG&amp;quot;,
              fv!item = &amp;quot;u&amp;quot;,
              &amp;quot;UNDERLINE&amp;quot;,
              left(fv!item,1) = &amp;quot;a&amp;quot;,
              {},
              &amp;quot;&amp;quot;
            )
          )
        ),
        link: tostring(
          rule!GLBL_UTIL_removeBlankValuesFromArray(
            touniformstring(
              a!forEach(
                trim(split(local!list4, &amp;quot;;&amp;quot;)),
                extract(fv!item, &amp;quot;a{{&amp;quot;, &amp;quot;}}&amp;quot;)
              )
            )
          )
        )
      }
    )
  )
)


/* rule!GLBL_UTIL_FormatHTMLLinebreaksForTextDisplay */
a!localVariables(
  local!lineBrokenText: regexreplaceall(
    &amp;quot;&amp;lt;br */*&amp;gt;&amp;quot;,
    substitute(
      substitute(ri!htmlText, char(13), &amp;quot;&amp;quot;),
      char(10), 
      &amp;quot;&amp;quot;
    ),
    char(10)
  ),
  
  local!lineBrokenText
)&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Note that this is 3 separate expression rules; also they make use of a few helper expression rules (like &amp;quot;ReplaceNull&amp;quot; and &amp;quot;RemoveBlankArrayMembers&amp;quot;) that you may need to implement yourself in your own system and swap in for the rules named in these.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: markdowntosail function</title><link>https://community.appian.com/thread/80590?ContentTypeID=1</link><pubDate>Tue, 30 Mar 2021 12:52:52 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:f05c2916-a998-4bdb-a73b-9a770bdbbd46</guid><dc:creator>Michal B&amp;#246;nisch</dc:creator><description>&lt;p&gt;Hi Mike, I am looking for the expression rule that you described in your post.&amp;nbsp;W&lt;span&gt;ould you be willing to share your code with me or post it here? thank you.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: markdowntosail function</title><link>https://community.appian.com/thread/74461?ContentTypeID=1</link><pubDate>Mon, 01 Jun 2020 08:28:10 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:ddceed83-e0cf-49f5-9857-e74bf4e033a9</guid><dc:creator>Dai Williams</dc:creator><description>&lt;p&gt;Thanks Mike, that would be really useful if you could. I have ended up doing something similar but I am at the early stages of it.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: markdowntosail function</title><link>https://community.appian.com/thread/74460?ContentTypeID=1</link><pubDate>Mon, 01 Jun 2020 08:27:59 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:9817ec71-7600-4c43-9e03-86008cf82a43</guid><dc:creator>Dai Williams</dc:creator><description>&lt;p&gt;Thanks Mike, that would be really useful if you could. I have ended up doing something similar but I am at the early stages of it.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: markdowntosail function</title><link>https://community.appian.com/thread/74459?ContentTypeID=1</link><pubDate>Sun, 31 May 2020 15:27:06 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:02f95dd9-ab26-4559-8997-593578e086e1</guid><dc:creator>Mike Schmitt</dc:creator><description>&lt;p&gt;In the past I&amp;#39;ve written out-of-box Appian expression rules that parse certain simple HTML formatting to display in Rich Text on an Appian form (read-only of course).&amp;nbsp; It only supports bold, italic, underline, linebreaks, and hyperlinks.&amp;nbsp; If that sounds like enough for you, then I could dig up and attempt to post them here. Note it also does require the Regex Utilities plug-in.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>