LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 07-17-2020, 12:25 PM   #1
SpacePlod
Member
 
Registered: Jan 2014
Distribution: Slackware
Posts: 115

Rep: Reputation: Disabled
pandoc: md --> html --> pdf: Code Block issues


Good morning/afternoon/evening,

I'm having an issue with pandoc/wkhtmltopdf on Slackware. When trying to convert from markdown to pdf via html (so that I can use css), I get extra unwanted line breaks in the pdf inside code blocks.

Sample markdown:
Code:
### Python Code

```python
#!/bin/env/python  
def myfunc():  
    i = input("Enter a value: ")  
    return i
x = myfunc()  
```
pandoc command:
Code:
pandoc -t html -o sample.pdf sample.md
Output is shown in the attached image. You can see both lines in the function def have unwanted line breaks. This happens with all code blocks (```bash, etc.) when using syntax highlighting.

Pandoc does a fine job of md --> html and md --> pdf and html --> pdf. The code comes out correct. But the css does not appear to get applied unless I use "--css=mycss -t html" on the command line.

I'm using the pandoc-bin package from SBo. I've tried the pandoc package, but I cannot get ghc to build. Interestingly, this is not an issue on Manjaro or Ubuntu (VMs) - the command with "--css -t html" works as expected.

I posted this question to the pandoc users google group and the response was to convert to html and examine the html output. This does not help because the html produced that way renders fine. Since this is only happening on Slackware (in my limited testing) I thought I'd post here in case someone has any ideas. I've looked at the build scripts for wkhtmltopdf and pandoc and I don't see any build options that jump out at me as likely culprits.

Thanks,
Attached Thumbnails
Click image for larger version

Name:	sample1.png
Views:	45
Size:	8.8 KB
ID:	33674  
 
Old 07-18-2020, 04:56 AM   #2
Qury
Member
 
Registered: Feb 2004
Location: Naas,IE
Distribution: Slackware
Posts: 212

Rep: Reputation: 184Reputation: 184
Try zettlr. I use that with pandoc to convert my md files to other formats
 
Old 07-21-2020, 04:44 PM   #3
SpacePlod
Member
 
Registered: Jan 2014
Distribution: Slackware
Posts: 115

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by Qury View Post
Try zettlr. I use that with pandoc to convert my md files to other formats
Thanks for the pointer. I looked into it and it looks pretty powerful, but I'd really like to keep this to a simple set of commands that I can script. Looks like zettlr is a full GUI.
 
Old 07-22-2020, 03:27 PM   #4
SpacePlod
Member
 
Registered: Jan 2014
Distribution: Slackware
Posts: 115

Original Poster
Rep: Reputation: Disabled
Interesting update in case someone comes across this same issue down the road...

I found that if I add 2 spaces after the lines that have the extra newline, then it will render correctly. I'm not sure why this only happens on some of the lines in syntax highlighted code, but adding the extra spaces resolves the issue.

Interesting that this is not required for the exact same markdown file/pandoc command on Manjaro or Ubuntu. I still cannot see any compile time arguments that might result in this behavior, but I'm also not going to go through all the haskell deps either. But given that I'm using pandoc-bin (SBo) - which is the repackaged bin from upstream, this should not be the issue.

For now I'll mark this solved since there is a work around, but it's a bit annoying to add spaces to code pulled from a buffer, so I'll keep working at it and update if there is a better solution (or explanation).

Last edited by SpacePlod; 07-22-2020 at 03:28 PM. Reason: spelling
 
Old 07-24-2020, 11:51 AM   #5
SpacePlod
Member
 
Registered: Jan 2014
Distribution: Slackware
Posts: 115

Original Poster
Rep: Reputation: Disabled
Another update: Had to remark this as unsolved...

I was using -current in my previous posts. The 2 space addition to code lines in code blocks seems to work for current. But under 14.2 the problem is still there. Code with syntax highlighting still renders with extra newlines inside functions where there is any indentation (bash, python, etc.). Adding spaces to the end of each line of code has no effect.

On 14.2 (with spaces at the end of indented code):
Code:
Code:
```python
def myfunc(a,b):
     i = a + b 
     return i 

print(myfunc(2,2))
```
Command:
Quote:
pandoc -t html -o sample.pdf sample.md
The attached is what is rendered.

So I'm still looking for a solution.
Attached Thumbnails
Click image for larger version

Name:	Screenshot_2020-07-24_12-47-17.png
Views:	16
Size:	6.5 KB
ID:	33706  
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Installing Pandoc on -current x86_64: the easy way dugan Slackware 6 01-16-2018 08:35 PM
Installing Pandoc in Slackware with Stack reclusivewriter Slackware 5 03-15-2017 09:33 AM
pandoc (a universal document converter) vonbiber Slackware 4 11-27-2016 09:16 AM
pandoc for pdf generation a4z Slackware 7 07-17-2014 01:40 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 08:11 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration