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

Removing empty line that produces an invalid '-->' output when importing md #1601

Closed
wants to merge 1 commit into from

Conversation

@magmax
Copy link
Member

magmax commented Jan 27, 2015

When importing markdown, this line produces metadata like these:

<!--
.. title: foo
.. slug: bar
.. date: 2001/01/01

-->

That is processed genarating the line:

<p>--&gt;</p>

What is invalid.

This fix will generate metadata like:

<!--
.. title: foo
.. slug: bar
.. date: 2001/01/01
-->

What is processed as expected.

@Kwpolska
Copy link
Member

Kwpolska commented Jan 27, 2015

This will break reStructuredText though.

Markdown, HTML, etc. need:

<!--
.. title: foo
-->

text

reStructuredText needs:

.. title: foo

text
@magmax
Copy link
Member Author

magmax commented Jan 27, 2015

No, it doesn't because in file nikola/plugins/compile/rest/__init__.py:

        with io.open(path, "w+", encoding="utf8") as fd:
            if onefile:
                fd.write(write_metadata(metadata))
                fd.write('\n')
            fd.write(content)

So the line feed is already there.

@Kwpolska
Copy link
Member

Kwpolska commented Jan 27, 2015

Okay. What do you mean by importing? Do you mean nikola new_post -i /path/to/other/md/file.md?

If yes, you fixed the wrong place. On your branch, all the compilers generate garbage in new posts:

.. type: text-->

Write your post here.
.. type: text
Write your post here.

And in imported posts:

(nikola-py2)[kwpolska@kw-cassandra /tmp]% nikola init -q n
[2015-01-27T08:44:01Z] INFO: init: Created empty site at n.
(nikola-py2)[kwpolska@kw-cassandra /tmp]% cd n
(nikola-py2)[kwpolska@kw-cassandra n]% vim conf.py import.md
# markdown support added to POSTS
(nikola-py2)[kwpolska@kw-cassandra n]% cat import.md
This is a post that I am willing to import.
(nikola-py2)[kwpolska@kw-cassandra n]% nikola new_post -f markdown -t imp -i import.md
Importing Existing Post
-----------------------

Title: imp
Scanning posts.....done!
[2015-01-27T08:54:19Z] INFO: new_post: Your post's text is at: posts/imp.md
(nikola-py2)[kwpolska@kw-cassandra n]% cat posts/imp.md
<!-- 
.. title: imp
.. slug: imp
.. date: 2015-01-27 08:54:19 UTC
.. tags: 
.. category: 
.. link: 
.. description: 
.. type: text-->

This is a post that I am willing to import.
  1. What are you doing to import posts?
  2. What are you importing?
  3. Can you reproduce with a clean site (extended only to support markdown)?
@magmax
Copy link
Member Author

magmax commented Jan 27, 2015

Hmmm.... Ok. I start thinking you are right and the best place to fix it is in the metadata read, instead the write.

I will try to fix it as soon as I can.

Thank you!

@magmax magmax force-pushed the magmax:master branch from 6a88a93 to cbb9204 Jan 28, 2015
@magmax
Copy link
Member Author

magmax commented Jan 30, 2015

I have a headache with this issue.

The last change will fix my problem, but I think it is changing the behavior so much that it may fail to someone that was using it incorrectly.

IMHO, there should be just one way to do that: as a comment or not.

But without my fix, Markdown will fail for any document with several spaces before the -->

@Kwpolska
Copy link
Member

Kwpolska commented Jan 30, 2015

👎

Fix your plugin. Period.

@Kwpolska Kwpolska closed this Jan 30, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants
You can’t perform that action at this time.