html-entities

Benchmark created by obedm503 on


Preparation HTML

<script>
function unescape(text){
        var regexp = /(&amp;|&lt;|&gt;|&quot;|&#39;)/g;
        if( regexp.test(text) ){
          var entities = {
              "&amp;": "&",
              "&lt;": "<",
              "&gt;": ">",
              "&quot;": "\"",
              "&#39;": "'"
          };
          text = text.replace(regexp, function(ent){
            return entities[ent];
          });
        }
        return text;
}
function unescapeReplace(text){
        return text
          .replace(/&amp;/g, '&')
          .replace(/&lt;/g, '<')
          .replace(/&gt;/g, '>')
          .replace(/&quot/g, '"')
          .replace(/&#39/g, "'");
      }
var text = `
### Test about parsing <   > 
This is a test about parsing text between "chevrons" <   > as HTML tags:

### Inline code
First test is about some <tags> inside backticks, or _inine code_;
First test is about some &lt;tags&gt; inside backticks, or _inine code_;

### Inside code block
Second test is about what seems like SGML tags inside a code block:

<html></html>

    vnoremap <silent> "$ :w !nc -q0 localhost 5900<CR>

With the  as _html entities_:

    vnoremap &lt;silent&gt; "$ :w !nc -q0 localhost 5900&lt;CR&gt;

Using ***bootmark*** I can't see the 
`;
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
function
unescape(text)
ready
replace
unescapeReplace(text)
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.

  • Revision 1: published by obedm503 on