You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Apr 10, 2024. It is now read-only.
Idea
It would be a nice feature being able to define custom empty elements to be handled by
json2html
function.Use case
I am parsing an html block in order to make it amp valid html so among a lot of custom amp tags I have to transform
img
toamp-img
.Problem
json2html
function is handling a predefined list of empty elements:html2json/src/html2json.js
Lines 125 to 152 in ef49d49
After parsing my html and modifying the img tag, I want to convert it back to html so I have this situation:
Initial tag:
<img src="example.jpg"/>
Expected result:
<amp-img src="example.jpg"/>
Actual result
<amp-img src="example.jpg"></amp-img>
Proposed solution
Adding an options object to
json2html
so we can push our custom tags to the predefined list would be enough to make it work.I made a pull request (#38) with the proposed solution and a test to make sure it works.
The text was updated successfully, but these errors were encountered: