-
Notifications
You must be signed in to change notification settings - Fork 237
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
How to customize res path when writing Appledict #412
Comments
Can you upload the source glossary you are coverting from? |
Actually I’m not converting. I’m using pyglossary to write entries into a new dict. |
And here is the code: Glossary.init()
glossary = Glossary()
file_loader = FileSystemLoader('templates')
env = Environment(loader=file_loader)
template = env.get_template('template.html')
with open('dict.json') as f:
dictionary: list = json.load(f)
for item in dictionary.__iter__():
glossary.addEntryObj(glossary.newEntry(
item['symbol'],
template.render(
alias_name=item['symbol'],
fullname=item['name'],
details=item['details'],
),
defiFormat='h',
))
glossary.addEntryObj(glossary.newEntry(
item['name'],
template.render(
alias_name=item['symbol'],
fullname=item['name'],
details=item['details'],
),
defiFormat='h',
))
glossary.setInfo("title", "Elements Dictionary")
glossary.setInfo("author", "EvanLuo42")
glossary.write(filename='Elements Dictionary', format='AppleDict', css='templates/template.css') <div class="words">
<div class="word"><h1 id="alias-name">{{ alias_name }}</h1></div>
<div class="word"><h3 id="full-name">{{ fullname }}</h3></div>
</div>
<div class="defi">
{% for amount_name, amount in details.items() %}
<div class="content">
<b class="amount">{{ amount }}</b>
<div class="amount_name">{{ amount_name }}</div>
<img src="img/a.jpeg">
</div>
{% endfor %}
</div> P.S. That |
What I want to do is to add some pictures into some entries. But if I just write |
Then you need to add your images (or css, js or other files) as Data Entries. For example: with open("img/a.jpeg") as fp:
glos.addEntryObj(glos.newDataEntry("img/a.jpeg", fp.read())) The first argument to |
Ok, got it. Thank you. |
If I just use image with
<img src="img/some.jpeg">
,some.jpeg
will not be moved to OtherResources when generating Appledict source. I checked write options, but I did not find an option which is satisfied with this need.The text was updated successfully, but these errors were encountered: