I'm not worried about supporting sections, although a bounty would be given for doing so :)
Here's what I have so far, but it produces strange output for #2
:
\begin{filecontents}{test}
\Property this property = some value
\Property k = v
\end{filecontents}
\documentclass{article}
\usepackage{expl3}
\ExplSyntaxOn
\cs_new:Npn \Property #1=#2^^M
{
1:#1\par
2:#2\par
}
\ExplSyntaxOff
\begin{document}
\input{test}
\end{document}
Ideally, I would like to have a syntax like
\begin{filecontents*}{test.conf}
this property = some value
k = v
# bounty
[section]
property=value
\end{filecontents*}
\documentclass{article}
\usepackage{xparse}
\ExplSyntaxOn
\begin{document}
\conf_load:Nn \l_tmpa_prop { test.conf }
% outputs {some value} (brace groups irrelevant)
\conf_get:Nn \l_tmpa_prop { this ~ property }
% bounty; outputs {value} (brace groups irrelevant)
\conf_get:Nnn \l_tmpa_prop { section } { property }
\end{document}
How can this be accomplished? I should note that the details of the interface / naming is just a suggestion.
Ideas
(a work-in-progress list)
- Reading in the file and mapping a macro over each line; doesn't support sections
- Making necessary characters active for the read and practicing dark magic
datatool
package. Do you have a preference for usingexpl3
? Also, it would be helpful if your provided an actual list of<property name>
,<property value>
pairs. Specifically do you need to be able to handle any of the special LaTeX characters ? – Peter Grill Sep 29 '14 at 18:15expl3
, but if a wrapper can be created, I'm fine with that. :) – Sean Allred Sep 29 '14 at 18:17