0

I'm trying to import an markdown file into an HTML. I've used the iframe tag to do so but it is shortening the content inside a box. As I'm using markdown to write the text thats going inside the main tag, so my intention is that it keeps the height of the text in markdow. I also used the lib https://cdnjs.cloudflare.com/ajax/libs/iframe-resizer/4.3.2/iframeResizer.min.js but it didn't worked. And a common import, and it didnt work it either. The codes are the following: HTML

<!DOCTYPE html>
<html lang="">
<head>
<meta charset="utf-8">

<!-- CSS styles -->
  <link rel="stylesheet" href="style.css">
  <link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css"/>
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.1/css/fontawesome.min.css" />
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.1/css/solid.min.css" />
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.2/css/brands.min.css"/>
  <link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css" />

<!-- Javascript -->

  <script src="https://cdnjs.cloudflare.com/ajax/libs/iframe-resizer/4.3.2/iframeResizer.min.js" integrity="sha512-dnvR4Aebv5bAtJxDunq3eE8puKAJrY9GBJYl9GC6lTOEC76s1dbDfJFcL9GyzpaDW4vlI/UjR8sKbc1j6Ynx6w==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
  <!-- Lightweight client-side loader that feature-detects and load polyfills only when necessary -->
  <script src="https://cdn.jsdelivr.net/npm/@webcomponents/webcomponentsjs@2/webcomponents-loader.min.js"></script>
  <!-- Load the element definition -->
  <script type="module" src="https://cdn.jsdelivr.net/gh/zerodevx/zero-md@1/src/zero-md.min.js"></script>

  <script type="module" src="javascript.js"></script>
  <!-- Simply set the `src` attribute to your MD file and win -->
  <script type="module" src="https://cdnjs.cloudflare.com/ajax/libs/markdown-it/12.2.0/markdown-it.js"></script>
<title></title>
</head>
<body>
<header>Header</header>
 <aside>
  <div id="mySidenav" class="sidenav">
    <p>nav bar</p>
  </div>
 <aside>
<main>
 <!-- include my markdown file here -->
<!-- try 1 -->
<link href="mkd.md" rel="import" />

<!-- try 2 -->
<pre class="hljs"><code>
<link class="hljs rel="import" href="mkd.md">
</code></pre>

<!-- try 3-->
<div w3-include-html="mkd.md"></div>

</main>
<footer>Footer</footer>
</body>
</html>

CSS:

header{
    background-color: #000000;
    padding-left: 4%;
    padding-top: 1%;
    padding-bottom: 1%;
    margin-top: -0.001%;

}
main{
    padding-left: 4%;
 max-width: 86%; // set maximum width of the container
  white-space: wrap; // do not let text wrap
  overflow: hidden; // do not let overflow out of container
  text-overflow: ellipsis; // shorten all overflowing text
}


body, html,main {
  height:100%;
  width:100%;

}

iframe {
  height:100%;
  width:100%;
  background:cyan;}


  #mySidenav a  {
  position: fixed;
  left: -230px;
  transition: 0.3s;
  padding: 15px;
  width: 270px;
  text-decoration: none;
  font-size: 20px;
  color: white;
  border-radius: 0 5px 5px 0;
  margin:0;
  padding-top: 0;
padding-bottom: 0;

}

And I used a markdown available at https://markdown-it.github.io/ All the solutions I've found it I had to install a package, is there a way to do it just importing it ?

Edited: enter image description here

There is a scroll bar and if I remove it doesn't show the whole content, and the markdown is plain, it not enhanced, as it should be since I'm using <script type="module" src="https://cdnjs.cloudflare.com/ajax/libs/markdown-it/12.2.0/markdown-it.js"></script>

Thanks you all guys!

user2535338
  • 355
  • 4
  • 20
  • Do you want it to be parsed to html? Or do you just want the raw markdown content displayed? – Eelke van den Bos Oct 15 '21 at 14:01
  • I do think you can use iframe for this kind of problem, but you have to use some JavaScript to resize the iframe: [Make iframe automatically adjust height according to the contents without using scrollbar?](https://stackoverflow.com/a/9976309/8875607) – Pøziel Oct 15 '21 at 14:11
  • I what the content parsed to html. And I've already tried this @AlexandreSauvé and didn´t worked either – user2535338 Oct 15 '21 at 14:34
  • I've used `embed` tag but it has the same behavior. I Added the print that the flowwoing code generated : ` ` I'didn´t found any solution to my problem – user2535338 Oct 15 '21 at 17:11

0 Answers0