Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Feature Request: Support markdown in --reporters html output #1309

Open
testmonger opened this Issue Nov 29, 2017 · 2 comments

Comments

4 participants
@testmonger
Copy link

testmonger commented Nov 29, 2017

  1. Newman Version (can be found via newman -v): 3.8.3
  2. OS details (type, version, and architecture): Win 10 Home
  3. Are you using Newman as a library, or via the CLI? CLI
  4. Did you encounter this recently, or has this bug always been there: always
  5. Expected behaviour: markdown syntax formatted appropriately in newman html report.
  6. Command / script used to run Newman:
    newman run %collection% --environment %p_envir% --ssl-client-cert %p_cert% --ssl-client-key %p_key% --ssl-client-passphrase %pp% --reporters html
  7. Sample collection, and auxilliary files (minus the sensitive details):
  8. Screenshots (if applicable): N/A

Steps to reproduce the problem:

  1. Edit collection description to include markdown. Example:
    Functional Test Plan
    =================================

Overview

  1. Export the collection to the newman working directory
  2. Run the newman script, as indicated in step 5.

Expected: html report displays markdown as html styles (like heading 1).
Actual: report shows markdown syntax instead of rendering as html tag format. example:
Description: Functional Test Plan ================================= Overview -------- executes a series of API level tests to verify the functional accuracy

@shamasis

This comment has been minimized.

Copy link
Member

shamasis commented Jun 14, 2018

care must be taken to sanitise the output.

@shamasis shamasis added this to the v4.0 milestone Jun 16, 2018

@filipeamaral

This comment has been minimized.

Copy link

filipeamaral commented Jul 18, 2018

I was able to successfully apply markdown -> html transformations, in collection and requests descriptions, by implementing a workaround with the help of Remarkable.
Just take the default template used by newman and apply the following changes:

Add to <head> (provide different lib versions if necessary)

<script src="https://cdn.jsdelivr.net/combine/npm/jquery@3.3.1,npm/bootstrap@3.3.7/dist/js/bootstrap.min.js,npm/remarkable@1.7.1/dist/remarkable.min.js"></script>

Add to end of <body>

<script type="text/javascript">
    const remarkable = new Remarkable();
    
    const collectionDescription = document.querySelector("#collectionDescription");
    
    if(collectionDescription) {
        collectionDescription.innerHTML = renderHtmlFromMarkdown(collectionDescription.textContent);
    }
    
    const requestDescriptions = document.querySelectorAll("#requestDescription");

    requestDescriptions.forEach(requestDescription => {
        requestDescription.innerHTML = renderHtmlFromMarkdown(requestDescription.textContent);
    });

    function renderHtmlFromMarkdown(markdown) {
        return remarkable.render(trim(markdown));
    }

    function trim(string) {
        return string ? string.replace(/^ +| +$/gm, "") : string;
    }
</script>

Don't forget to provide the new template through newman options, e.g.:

"reporter": {
    "html": {
        "export": "report.html",
        "template": "new-template.hbs"
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.