Skip to content
Grav 2.0 is officially stable. Read the announcement →

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

Support

Adding <iframe> to .md not working

Solved by pamtbaau View solution

Started by Junillon 6 years ago · 10 replies · 23115 views
6 years ago

Hi there
May be this will be a stupid question, but... I can't find out any potential solution to my problem. I rather new to grav, creating a simple site, and I found this cms fantastic. but...
I want to add an iframe in a simple page. So I try, as I read it in another post, to insert my html code in the .md.
The result is just a render text with "<iframe..." . I thought markdown was simply accepting html tags.
I went in the system config, markdown is set to true, markdown_extra also (btw I don't know what it means). I parsed grav admin to ensure everything was ok, it seems too.
Other markdown styles are working like ## or ** and so on.
If anyone could give an idea, it would be great !
thanks a lot

👍 1
6 years ago

Markdown in general accepts all HTML-tags, but the iFrame-tag and a few others are disabled by default because they pose a security risk. You can customize this in system.yaml.

6 years ago

Well How could could I missed it ! thanks a lot for answering.
But... I must be missing something else.
I remove the tag from xss_dangeroustag in user/config/security.yaml
I also tried to set dangerous_tags to false
I cleared cache (wich also touch the new security file)

And I still get an iframe text 😦
so what do I do wrong again ?

last edited 08/26/20 by Junillon
6 years ago

@Francois, Markdown is not being processed when embedded inside an HTML block element.

I added the following snippet (showing an OpenStreetMap) to a Markdown file using vscode. I made no changes to security.yaml.

HTML
<div>
  <iframe id="inlineFrameExample"
      title="Inline Frame Example"
      width="300"
      height="200"
      src="https://www.openstreetmap.org/export/embed.html?bbox=-0.004017949104309083%2C51.47612752641776%2C0.00030577182769775396%2C51.478569861898606&layer=mapnik">
  </iframe>
</div>

image|539x371

Note: I did not try adding the snippet from withing Admin plugin.

last edited 08/26/20 by pamtbaau
6 years ago

@pamtbaau @OleVik so kind to answer :) but no :( stills not working.... here is what I get.
Editing or not security.yaml going to the same result, there must be something stupidly wrong in my config. Is there any special command to reload part of the cms ?

Capture d’écran 2020-08-27 à 08.16.19|690x349

6 years ago

@Francois, I ran my test (again) on a fresh Grav 1.6.26 installation and it worked without any changes to Grav, except adding the snippet into '/pages/02.typography/default.md' using vscode.

Would you mind downloading a fresh copy of Grav 1.6.26 and try again? If that is working you can apply the changes of your original site into the new one, one by one.

6 years ago

OK ! you were right :) someting went wicked in my config 😦
after a fresh install, I can use iframe tag without any problem.
I tryed to copy all "user" dir from my sav dir to get my pages back, and problem starts again. If I've some time, I'll try to compare...
Actually I'm going to recreate. Second try is allaways better than first one ;)
thanks a lot for your time helping me !

6 years ago

@Francois, Copying entire /user folder might be too much, because it will be very likely the issue is somewhere in that folder...

My approach would be:

  1. Start with fresh install
  2. Copy from original site folders/files from low probable impact to high and check after each step.
    1. Create test page with working <iframe>
    2. Copy /pages folder. Is <iframe> in copied page working?
      If not, take a look at its frontmatter.
    3. Install fresh theme
    4. Install fresh plugins one by one
    5. Copy theme config file
    6. Copy plugin config file
    7. Copy site.yaml into /config
    8. Copy system.yaml into /config
    9. ...

Please feed back to the community the cause of the issue.

last edited 08/28/20 by pamtbaau
6 years ago

Yes, found it, and it was a little stupid... from me !
in user/config/system I had place :

YAML
markdown:
    escape_markup: true

this result in removing capabilities to insert simple tag as they are escaped :sleepy:
I set it to false and everything is good.

again, thanks a lot !

last edited 08/28/20 by pamtbaau
6 years ago Solution

@Francois, Smart cookie... ;-)

No need to set it to false, just delete it because false is the default. See '/system/config/system.yaml':

YAML
markdown: 
  ...
  escape_markup: false               # Escape markup tags into entities

Suggested topics

Topic Participants Replies Views Activity
Support · by Thomas, 1 week ago
2 54 12 hours ago
Support · by Anna, 3 days ago
2 60 15 hours ago
Support · by Justin Young, 15 hours ago
1 30 15 hours ago
Support · by Duc , 1 week ago
2 65 5 days ago
Support · by Colin Hume, 1 week ago
2 57 5 days ago