This project has moved. For the latest updates, please go here.

Style attributes in span tag

Jan 6, 2016 at 11:27 AM
When in SP2013 I use a rich text field, and use underlined text via:
<span style="text-decoration: underline;">Underlined text</span>
It is not parsed to underlined text in OpenXML, when using the <u> tag:
<u>Underlined html text</u>
It gets underlined in OpenXML. Is it possible that style attributes within span tags are not supported?
Coordinator
Jan 6, 2016 at 11:43 AM
Do you have a more complete sample? Because it actually works well with text-decoration: underline.
Jan 6, 2016 at 12:40 PM
Edited Jan 6, 2016 at 12:47 PM
In SharePoint 2013:
<div class="ExternalClass9941B65AA8254604A296EE47EDD5FA0C">
   <p> 
      <u>underlined text with u tag</u> </p>
   <p> 
      <span style="text-decoration: underline;">underlined via span</span> </p>
</div>
In ASP.Net via Sp Webservice:
"<div class="ExternalClass9941B65AA8254604A296EE47EDD5FA0C"><p>       <u>underlined text with u tag</u> </p><p>       <span style="text-decoration&#58;underline;">underlined via span</span> </p></div>"
After parsing in ASP.Net via:
converter = {NotesFor.HtmlToOpenXml.HtmlConverter}
cResult As IList = converter.Parse(paragraphText)
IList with 3 paragraphs, OuterXml contents:
(0): "<w:p xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"><w:r><w:rPr><w:u w:val="single" /></w:rPr><w:t xml:space="preserve">underlined text with u tag</w:t></w:r></w:p>"
(1): "<w:p xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"><w:r><w:t xml:space="preserve">underlined via span</w:t></w:r></w:p>"
(2): "<w:p xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"><w:r><w:br /></w:r></w:p>"
Analyzed via Open XML SDK 2.5 Productivity tool:
<w:r xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main">
  <w:rPr>
    <w:rFonts w:ascii="ING Me" w:hAnsi="ING Me" />
    <w:sz w:val="20" />
  </w:rPr>
  <w:t />
  <w:p>
    <w:r>
      <w:rPr>
        <w:rFonts w:ascii="ING Me" w:hAnsi="ING Me" />
        <w:sz w:val="20" />
      </w:rPr>
      <w:rPr>
        <w:u w:val="single" />
      </w:rPr>
      <w:t xml:space="preserve">underlined text with u tag</w:t>
    </w:r>
  </w:p>
  <w:p>
    <w:r>
      <w:rPr>
        <w:rFonts w:ascii="ING Me" w:hAnsi="ING Me" />
        <w:sz w:val="20" />
      </w:rPr>
      <w:t xml:space="preserve">underlined via span</w:t>
    </w:r>
  </w:p>
  <w:p>
    <w:r>
      <w:rPr>
        <w:rFonts w:ascii="ING Me" w:hAnsi="ING Me" />
        <w:sz w:val="20" />
      </w:rPr>
      <w:br />
    </w:r>
  </w:p>
</w:r>
It seems that the runProperties for the <u> tag are converted nicely, but not for the span tag.
BTW, using the HtmlToOpenXML.dll version 1.5.0.0, installed via nuget, 1.6.0.0 not yet available at nuget...
Jan 6, 2016 at 1:12 PM
Tried with version 1.6, same result...
Coordinator
Jan 6, 2016 at 1:31 PM
Edited Jan 6, 2016 at 2:09 PM
Well it seems self explicit with the result of the web service. SP converts the ":" of the style attribute to "& # 58 ;" and I really don't handle that character.
I will update the base code to support it.

About the nuget package, I wasn't the owner until today :-)
So now, I will be able to release a new version.

Thank you for your feedback
Marked as answer by Robin391 on 1/6/2016 at 5:35 AM
Jan 6, 2016 at 1:35 PM
Thank you for your prompt response!
Coordinator
Jan 6, 2016 at 3:45 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.