I am using the Contentful API to download some content. It appears as a json object for my Node server, which passes it to my Angular interface. Content in json object contains raw markup text.
For example, an Angular call might look like this:
var id = "asdf76f7g68sd7g";
$http.get("/api/article/" + id).then(function(res){
$scope.article = res.data;
});
The object for $ scope.article will look something like this:
$scope.article = {
title: "Some title",
content: "Lorem ipsum [dolor](http://google.com) sit amet, consectetur adipiscing elit. Integer iaculis turpis ut enim eleifend venenatis. Proin nec ante quis nulla porta finibus. Suspendisse at [mauris](http://google.com) nisi."
};
In my HTML, I would then display the content as follows:
<p>{{article.title}}</p>
<p>{{article.content}}</p>
The problem here is that markdown is not converted to HTML and displays how you see it in the object. How can I convert any markdown to HTML and display the results?
source
share