Giter Club home page Giter Club logo

markdown2salesforce's Introduction

Markdown to Salesforce Converter

This, like many other tools, evolved out of a necessity to increase velocity editing content, without fighting with the tools, formats or conversions.

It's a simple little bit of Python that I started writing after playing with the "Markdown Preview Enhanced" VSCodium extension. I also use MarkdownLint extensively while authoring my KB and HOWTO articles.

I prefer to keep my content in a single, portable format since I regularly have to post the same content to multiple, disconnected, incompatible sources (namely Salesforce and Confluence), so I chose Markdown as the "Source of Truth™" for all of my articles.

Ideally, I would have preferred Markdown Preview Enhanced to render this directly each time I saved the Markdown, using the VSCodium pandoc extension, but that didn't work as well as I'd hoped, due to some odd choices in hard-coding the CSS and HTML in the Mamu dependency pandoc uses. It can save to HTML at each save of the .md file, but the HTML it emits is incompatible with Salesforce or Confluence.

So my journey took me through dozens of different Python modules, including BeautifulSoup4, Markdown, Markdown2, lxml and finally mistune.

Mistune allowed me to wrestle the output HTML in a way that I can override what is emitted and transform the tags before they hit the disk or output stream. That was the missing piece to getting the Markdown compatible with Salesforce, so it would accept it and render it as a proper visual article with code blocks and other lists/headings intact.

I don't know why in 2020 everything we write in a browser, doesn't support Markdown as a base format, but that's a discussion for another time...

To use this, simply take one of your articles in Markdown format, and pass it as an argument to md2sf.py. It will transform the markdown into a modified format of HTML that Salesforce can ingest and render in its own Knowledgebase system.

./md2sf.py sample.md

The input .md file you pass in (sample.md in the above example), will be saved back as the same base filename with a .html extension.

$ ls -1 sample.*
sample.html
sample.md

Take that HTML and paste it into the Salesforce KB form under the "Source" view mode, then click "Source" again on that form to get Salesforce to re-render in its own format, suitable for saving.

That's it!

Use it in a docker container

docker build -t md2kb .

alias md2kb="docker run -ti --rm --mount type=bind,source=.,destination=/app -w /app -u $UID:$GID md2kb"

md2kb sample.md

markdown2salesforce's People

Contributors

desrod avatar roylez avatar jasimioni avatar dependabot[bot] avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.