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

Org reader: handle minlevel option differently. #5190

Merged
merged 1 commit into from
Jan 8, 2019
Merged

Conversation

leungbk
Copy link
Contributor

@leungbk leungbk commented Dec 30, 2018

When minlevel exceeds the original minimum level observed in the
file to be included, every heading should be shifted rightward.

Closes #5188.

When `minlevel` exceeds the original minimum level observed in the
file to be included, every heading should be shifted rightward.
if shift <= 0
then blk
else case blk of
case blk of
(Header lvl attr content) -> Header (lvl - shift) attr content
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it worth adding something that checks to make sure that lvl - shift is positive, leaving things alone otherwise?

@tarleb
Copy link
Collaborator

tarleb commented Jan 1, 2019

Thank you, this is looking good. I love the fact that deleting code seems to add more features.
I think we currently run into problems if someone uses :minlevel 0 (which is fine for org-mode, it demotes first-level headers to top-level paragraphs). Would that be easy to add? If not, simply preventing pandoc from behaving weirdly would be enough for now, I think.

@jgm
Copy link
Owner

jgm commented Jan 8, 2019

I think the check is needed, but I'll just merge this and add a further commit on top of it.

@jgm jgm merged commit 9dbcf16 into jgm:master Jan 8, 2019
@leungbk
Copy link
Contributor Author

leungbk commented Jan 8, 2019

Ugh, I'm really sorry for the delay--I've been busier than expected and had some computer problems as well.

Yeah, the == 0 for lvl - shift needs to be there, but I think the < 0 check belongs outside, in the blockFilter function. Right now a negative value would never get passed into shiftHeader. I wasn't familiar with safeRead, and never got around to learning some of the relevant types.

@jgm
Copy link
Owner

jgm commented Jan 8, 2019

No worries @leungbk! Thanks for the PR. I just didn't want it to languish and be forgotten.

jgm added a commit that referenced this pull request Jan 8, 2019
@jgm
Copy link
Owner

jgm commented Jan 8, 2019

@leungbk @tarleb have a look at commit 710a22e.
This seems to agree with the org exporter when minlevel == 0. (h1 becomes a regular paragraph, h2 becomes h1 -- that's not very useful behavior, but that's how it seems to work.)
It also guarantees we won't get header level < 1.

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

Successfully merging this pull request may close these issues.

None yet

3 participants