Merge pull request #644 from esteemapp/bugfix/596

fixed h tag height issue
This commit is contained in:
uğur erdal 2019-03-03 22:22:20 +03:00 committed by GitHub
commit 1d66da2a8d
2 changed files with 21 additions and 0 deletions

View File

@ -14,6 +14,20 @@ export default EStyleSheet.create({
color: '$primaryBlue',
fontFamily: '$primaryFont',
},
h4: {
fontSize: 15,
marginHorizontal: 10,
marginVertical: 5,
},
h1: {
fontSize: 30,
},
h2: {
fontSize: 25,
},
h3: {
fontSize: 20,
},
img: {
// height: 50,
marginTop: 10,

View File

@ -22,6 +22,7 @@ const urlRegex = /(http|ftp|https):\/\/([\w_-]+(?:(?:\.[\w_-]+)+))([\w.,@?^=%&:/
const aTagRegex = /(<\s*a[^>]*>(.*?)<\s*[/]\s*a>)/g;
const imgTagRegex = /(<img[^>]*>)/g;
const iframeRegex = /(?:<iframe[^>]*)(?:(?:\/>)|(?:>.*?<\/iframe>))/g;
const hTagRegex = /(<h([1-6])>([^<]*)<\/h([1-6])>)/g;
export const markDown2Html = (input) => {
if (!input) {
@ -81,6 +82,10 @@ export const markDown2Html = (input) => {
output = handleATag(output);
}
if (hTagRegex.test(output)) {
output = handleHTag(output);
}
// if (copiedPostRegex.test(output)) {
// output = handleMarkdownLink(output);
// }
@ -130,6 +135,8 @@ const handleATag = input => input.replace(aTagRegex, (link) => {
return link;
});
const handleHTag = input => input.replace(hTagRegex, tag => `<div>${tag}</div>`);
const handleMarkdownLink = input => input.replace(copiedPostRegex, (link) => {
const postMatch = link.match(copiedPostRegex);