From fe67cb1acc5d51f94710c049dbda246824a90b49 Mon Sep 17 00:00:00 2001 From: u-e Date: Wed, 27 Feb 2019 23:21:41 +0300 Subject: [PATCH] fixed h tag height issue --- .../postElements/body/view/postBodyStyles.js | 16 ++++++++++++++++ src/utils/markdownToHtml.js | 7 +++++++ 2 files changed, 23 insertions(+) diff --git a/src/components/postElements/body/view/postBodyStyles.js b/src/components/postElements/body/view/postBodyStyles.js index 778d7e85c..b77767f9a 100644 --- a/src/components/postElements/body/view/postBodyStyles.js +++ b/src/components/postElements/body/view/postBodyStyles.js @@ -14,6 +14,22 @@ export default EStyleSheet.create({ color: '$primaryBlue', fontFamily: '$primaryFont', }, + h4: { + fontSize: 15, + marginHorizontal: 10, + // height: 10, + marginBottom: 5, + marginTop: 5, + }, + h1: { + fontSize: 30, + }, + h2: { + fontSize: 25, + }, + h3: { + fontSize: 20, + }, img: { // height: 50, marginTop: 10, diff --git a/src/utils/markdownToHtml.js b/src/utils/markdownToHtml.js index da03d71e1..2929b874d 100644 --- a/src/utils/markdownToHtml.js +++ b/src/utils/markdownToHtml.js @@ -22,6 +22,7 @@ const urlRegex = /(http|ftp|https):\/\/([\w_-]+(?:(?:\.[\w_-]+)+))([\w.,@?^=%&:/ const aTagRegex = /(<\s*a[^>]*>(.*?)<\s*[/]\s*a>)/g; const imgTagRegex = /(]*>)/g; const iframeRegex = /(?:]*)(?:(?:\/>)|(?:>.*?<\/iframe>))/g; +const hTagRegex = /(([^<]*)<\/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 => `
${tag}
`); + const handleMarkdownLink = input => input.replace(copiedPostRegex, (link) => { const postMatch = link.match(copiedPostRegex);