Skip to content
New issue

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

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

Already on GitHub? # to your account

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

Open
testmonger opened this issue Nov 29, 2017 · 3 comments
Open

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

testmonger opened this issue Nov 29, 2017 · 3 comments

Comments

@testmonger
Copy link

  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
Copy link
Member

care must be taken to sanitise the output.

@filipeamaral
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"
    }
}

@aquibbaig
Copy link

aquibbaig commented Feb 24, 2020

@kunagpal @shamasis @testmonger Can I work on this?

@codenirvana codenirvana transferred this issue from postmanlabs/newman May 25, 2020
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

5 participants