Last active
July 16, 2019 18:07
-
-
Save grenzi/ed09877421fdfbb33e8eb70468ff8a32 to your computer and use it in GitHub Desktop.
a pretty basic html to text conversion function for Power Query / Power BI use
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let | |
Source = (txt as any) => let | |
removeOne = (input) => | |
let | |
text = Text.From(input), | |
length = Text.Length(text), | |
position = Text.PositionOf(text, "<"), | |
positionEnd = Text.PositionOf(text, ">"), | |
range = positionEnd-position+1, | |
result = if position >= 0 then Text.ReplaceRange(text, position, range, "") else input | |
in | |
result, | |
removeAll = (input) => | |
let | |
rmvOne = removeOne(input), | |
rmvAll = if Text.PositionOf(rmvOne, "<") >= 0 then @removeAll(rmvOne) else rmvOne | |
in | |
rmvAll, | |
ret0 = Text.Replace(txt, "</li>", Character.FromNumber(10)), | |
ret1 = Text.Replace(ret0, "<br>", Character.FromNumber(10)), | |
ret2 = Text.Replace(ret1, "<br/>", Character.FromNumber(10)), | |
ret3 = Text.Replace(ret2,"<li>", " • "), | |
ret4 = removeAll(ret3), | |
ret5 = Text.Replace(ret4, "&", "&"), | |
ret6 = Text.Replace(ret5, """, """"), | |
ret7 = Text.Replace(ret6, "<", "<"), | |
ret8 = Text.Replace(ret7, ">", ">"), | |
ret9 = Text.Replace(ret8, " ", " "), | |
return = Text.Trim(ret9) | |
in | |
return | |
in | |
Source |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment