getnikola / plugins

Extra plugins for Nikola
https://plugins.getnikola.com/
MIT License
57 stars 93 forks source link

[orgmode] how to stylized the output of a code #260

Open hilmandayo opened 6 years ago

hilmandayo commented 6 years ago

Hello. I am a newbie in using nikola (and still quite new to emacs). I want to use org-mode for my blog writing with nikola. So far so good. However, there is one thing that I do not know how to get it working.

I am using org-babel for code snippets and I got the syntax highlighting working by using the pygments. In org-babel, when a code snippets is executed, the result will be written under the code snippets (with #+RESULTS written above it). Optionally, I can also set a RESULTS drawer to it. How can I make it that the results of the code snippet to be specially handled so that it will appear looks like the 'output' of the source code above it during nikola build?

Below's images show the org-mode source code and its corresponding HTML result. The first one is the output of the org-babel with RESULTS drawer while the second one is without the RESULTS drawer.

As you can see, when the output is within the results drawer, the result of the code is not shown in the web at all while when the output is not within the results drawer, the output appears like a normal text.

screen shot 2018-03-22 at 11 12 18 screen shot 2018-03-22 at 11 11 19
necromuralist commented 5 years ago

Have you tried leaving the raw directive out? This produces an unformatted box from the print statement (sorry, I couldn't upload a screenshot for some reason).

#+begin_src ipython :session validation :results output :exports both
print("Training")
for path in training_path.iterdir():
    print(f"{len(list(path.iterdir())):,} images in {path.name}")

print("\nValidation")
for path in validation_path.iterdir():
    print(f"{len(list(path.iterdir())):,} images in {path.name}")    
#+end_src
necromuralist commented 5 years ago

Oh, I noticed the date after I posted it.

hilmandayo commented 5 years ago

Yes, leaving the raw and drawer did solve this problem.

hilmandayo commented 5 years ago

Oh, I noticed the date after I posted it.

I don't really get the meaning of this. What is it about?

necromuralist commented 5 years ago

I meant the post is from March of 2018, so you probably figured it out by now but never got around to closing the ticket.