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

Support maps of maps in front matter (theme Academic) #226

Open
andreas-h opened this Issue Oct 17, 2018 · 4 comments

Comments

Projects
None yet
2 participants
@andreas-h
Copy link

andreas-h commented Oct 17, 2018

I'm using the Academic Theme. They have a way of combing the homepage from several .md files, one could look like this, e.g.:

+++
# About/Biography widget.
widget = "about"
active = true
date = 2016-04-20T00:00:00

# Order that this section will appear in.
weight = 5

# List your academic interests.
[interests]
  interests = [
    "Artificial Intelligence",
    "Computational Linguistics",
    "Information Retrieval"
  ]

# List your qualifications (such as academic degrees).
[[education.courses]]
  course = "PhD in Artificial Intelligence"
  institution = "Stanford University"
  year = 2012

[[education.courses]]
  course = "MEng in Artificial Intelligence"
  institution = "Massachusetts Institute of Technology"
  year = 2009

[[education.courses]]
  course = "BSc in Artificial Intelligence"
  institution = "Massachusetts Institute of Technology"
  year = 2008
 
+++

# Biography

Lena Smith is a professor of artificial intelligence at the Stanford AI Lab. Her research interests include distributed robotics, mobile computing and programmable matter. She leads the Robotic Neurobiology group, which develops self-reconfiguring robots, systems of self-organizing robots, and mobile sensor networks.

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed neque elit, tristique placerat feugiat ac, facilisis vitae arcu. Proin eget egestas augue. Praesent ut sem nec arcu pellentesque aliquet. Duis dapibus diam vel metus tempus vulputate. 

How can I get ox-hugo to create these lists (like [interests = ...] and [[education.courses]] ...) which both span over several lines, in the front matter of the exported Markdown?

@kaushalmodi

This comment has been minimized.

Copy link
Owner

kaushalmodi commented Oct 17, 2018

So the day has finally come. Someone actually needs this feature? :P

This is a known limitation. See https://ox-hugo.scripter.co/doc/custom-front-matter/#maps-of-single-and-list-values: "Maps of maps are not supported.".

I didn't implement that because I wasn't sure if all the effort needed in designing this complicated feature would be worth it.

But now I'll think of a user-friendly way of entering this table meta data in Org that would translate to that TOML table.

I will work on this, but this feature is not a high priority.

@kaushalmodi

This comment has been minimized.

Copy link
Owner

kaushalmodi commented Oct 17, 2018

How can I get ox-hugo to create these lists (like [interests = ...] and [[education.courses]] ...) which both span over several lines, in the front matter of the exported Markdown?

Just to be clear, if you look at that link I pasted, the "interests" front-matter setting is already supported.

But the "education.courses", which is a TOML table of tables, is not yet.

@kaushalmodi kaushalmodi changed the title Support lists in front matter (theme Academic) Support maps of maps in front matter (theme Academic) Oct 17, 2018

kaushalmodi added a commit that referenced this issue Oct 17, 2018

@kaushalmodi kaushalmodi added wishlist and removed enhancement labels Oct 17, 2018

@kaushalmodi

This comment has been minimized.

Copy link
Owner

kaushalmodi commented Oct 17, 2018

@andreas-h Hello, I thought a bit more about this. While I won't have time implementing a full-fledged parsing of maps of maps type front-matter, I have added a brute-force solution that would work for any kind of front-matter in ca0e602.

See https://ox-hugo.scripter.co/doc/custom-front-matter/#front-matter-extra for details.

Here's a test case: https://ox-hugo.scripter.co/test/posts/front-matter-toml-toml-extra/ (see the Markdown source link in there for ox-hugo generated front-matter + content).

Here's the source of that test from the test suite:

** Extra Front-matter                              :extra:verbatim:src_block:
:PROPERTIES:
:EXPORT_HUGO_WEIGHT: 5
:EXPORT_HUGO_CUSTOM_FRONT_MATTER: :widget "about"
:EXPORT_HUGO_CUSTOM_FRONT_MATTER+: :active "true"
:EXPORT_HUGO_CUSTOM_FRONT_MATTER+: :interests '((interests . ("Artificial Intelligence" "Computational Linguistics" "Information Retrieval")))
:END:
*** TOML Front-matter                                                  :toml:
:PROPERTIES:
:EXPORT_HUGO_FRONT_MATTER_FORMAT: toml
:END:
**** Extra Front-matter (TOML, TOML extra)                       :toml_extra:
:PROPERTIES:
:EXPORT_FILE_NAME: front-matter-toml-toml-extra
:END:
{{{oxhugoissue(226)}}}

The ~#+begin_src toml :front_matter_extra t~ TOML block here will get
appended to the TOML front-matter.
#+begin_src toml :front_matter_extra t
# List your qualifications (such as academic degrees).
[[education.courses]]
  course = "PhD in Artificial Intelligence"
  institution = "Stanford University"
  year = 2012

[[education.courses]]
  course = "MEng in Artificial Intelligence"
  institution = "Massachusetts Institute of Technology"
  year = 2009

[[education.courses]]
  course = "BSc in Artificial Intelligence"
  institution = "Massachusetts Institute of Technology"
  year = 2008
#+end_src

#+begin_src toml
# this TOML block will export to the Markdown body
#+end_src
@andreas-h

This comment has been minimized.

Copy link
Author

andreas-h commented Oct 19, 2018

Hey, @kaushalmodi , that's so great - thanks a lot! This actually solves all my needs :-)

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