Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

YAML Front Matter is incorrectly rendered with Version 2.3.0 #29

Closed
ritti opened this issue Jun 17, 2019 · 5 comments
Closed

YAML Front Matter is incorrectly rendered with Version 2.3.0 #29

ritti opened this issue Jun 17, 2019 · 5 comments

Comments

@ritti
Copy link

ritti commented Jun 17, 2019

I'm using the following md file.

---
author: Author One
category: Category
keyword: [keyword1, keyword2]
---

# Test with YAML Front Matter

some text

I'm running into the following issue:

With Version 2.3.0 (MIISHanlder.dll Version 2.3.0) I'm facing the following behaviour regarding YAML Front Matter also when templating is disabled: All meta data is rendered within a <h2> tag in html:

MIIS_2 3_Test with YAML Front Matter

With Version 2.2.0 (MIISHandler.dll Version 2.2.0) this was not the case:
MIIS_2 2_Test with YAML Front Matter

I have a template with a placeholder for keywords where I use the YAML Front Matter keywords to add the html meta data DC.keywords

Template Material main.html

Templates_Material_main htm

Expected Behaviour:

DCkeywords_in_HTML

Behaviour with Version 2.3.0:
The variable will not be replaced and is empty because of the YAML Front Matter keywords are already converted to h2 tag.

@jmalarcon
Copy link
Owner

jmalarcon commented Jun 17, 2019

Hi,

I think you've made a small mistake since this works as expected. The problem, I guess, is that you have added some kind of space before the front-matter. For example, probably an empty line at the beginning of the file.

You must take into account that Front-Matter must be always the first thing in the file. This is by design and it works exactly the same way in any other CMS system such as Jekyll or Hugo. For example, in Jekyll you can't even have the BOM mark in UTF-8 files before the Front-Matter, which I think it's kind of crazy. In MIIS's case, it allows for more than 3 dashes as Front-Matter separator, but it absolutely must be the first thing in the file.

That means: no single space or new line must exists before Front-Matter or it will be considered a part of the content. That's what's happening in your case. Since the last --- are a way to define second level headers, that's why you're getting an <h2> with the FM as content. This works exactly the same in previous versions of MIIS, so it's something extra you've typed in your file since you' ve upgraded MIIS.

Solution: Just remove the extra spaces or new lines at the very top of the file and it'll work 😊

I've been working hard in my spare time on the new v3.0 of MIIS that will have tons of new features and nice new things. I hope to have it finished and polished in the next few weeks.

Cheers!

@ritti
Copy link
Author

ritti commented Jun 18, 2019

Hi,
thanks for the useful hint! I tested a little bit and found out that the jumping point is that the markdown files are in UTF8 with Unix Line ending style and not with Windows/DOS. When I store the file with DOS afterwards everything works as expected.
Question: Is this behavior also expected? I'm not sure if Jekyll or Hugo also expect this?

SampleYamlHeader md _UTF8_WindowsDOS_vs_Unix

Thanks a lot!

By the way: MIISHanlder.dll Version 2.2.0 didn't care about Unix or Windows/DOS.

@jmalarcon
Copy link
Owner

Hi,

Ah, ok, interesting... This is why attaching the original file is always a better idea than simply pasting the contents, because even a minor detail like this can influence the result.

In MIIS's case, to detect the Front-Matter I've used a simple regular expression If you check the specific line here you can see I'm using Environment.NewLine to detect the end of the FM. Therefore, it seeks for the current operating system's end of line. In Windows/IIS that means "\r\n". In Linux/UNIX it means "\n" and in Mac it means "\r". A nightmare IMHO. Although MIIS only works under Windows right now.

It could be easily changed so that any of them would be enough. I'll take that into consideration and think about possible problems of doing it.

However, Why are you using UNIX EOL style if you're working under Windows? Just for the sake of curiosity... Maybe you need to work with some co-workers that use Linux?

Cheers.

@ritti
Copy link
Author

ritti commented Jul 23, 2019

Hi,
sorry for the late answer.
Thanks for your clarification. I investigated and had a look where the "\n" end of lines come from.
In my scenario I have XML files that are converted by a open-source tool (DITA-OT) to markdown.
These files result in the UNIX EOL style.
Of course it would be nice if MIIS 2.3 also supports this style.
But I expect that you invest all your time in MIIS 3.0 that hopefully comes soon;-)
Thanks so far!

@jmalarcon
Copy link
Owner

Interesting.

Yes, I have v3.0 very advanced, with a huge set of new features and extensibility. I think the bits will be ready very soon, although I have a lot of documentation work to do before releasing the final product.

I've taken into account this problem with new lines in UNIX, and it will disappear in the new version.

You can check the v3 branch for a the new code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants