Newline in strings in add-ons configurations

AnkiWeb addon 112201952

Allows non-strict JSON configurations to contain literal newlines in strings, converting them to \n before loading and showing readable line breaks in the configuration editor.
AI-generated summary; may contain mistakes.

developer-tools

Open on AnkiWeb GitHub Find alternatives

AnkiWeb

Votes
2 (👍 2 · 👎 0)
Updated
2020-03-19
Anki versions
2.1.22~
License
GPL-3.0 (from the GitHub repository)
Virus scan
No ClamAV match A match does not prove malware. No match does not prove that the code is safe.
Languages
Python
Description language
en

Maintenance

abandoned

  • Last update or commit: 2020-08-02 (2282 days before the snapshot).
  • Commits in the last year: 0.
  • Issues: 1 open, 0 closed.
  • Pull requests: 0 open, 0 merged.
  • Median first response: 2 hours (1 answered issues and pull requests).

Will it work on my Anki?

Version branches
Min AnkiMax AnkiUpdated
2.1.02.1.212019-04-12
2.1.22+2020-03-19
History across monthly snapshots

Loading…

Similar addons

Field AutoComplete

Adds editor autocomplete that suggests existing values from the same note type and field, with toggleable suggestions and strict or loose search modes.

card-creationshortcutsfork-or-reupload

24 votes 69% approval 👍 21 · 👎 3 ⭐ 5 Anki 24.11~ Updated 2025-01-29
𝕾 Selected Notes to Structured Text (for LLMs)

Exports selected Anki notes as LLM-friendly structured text—copyable or saved—preserving field contents unchanged while including note type, deck path, and optionally tags.

export

2 votes 34% approval 👍 2 · 👎 0 ⭐ 3 Anki 26.09~ Updated 2026-08-24

Description

Allow to use non-strict json, with new lines in strings. Ensure that config editor show more readable content.

README

New line in strings in configurations/json

Rationale

In standard json, string should not contain newlines. They should contain "\n" instead, the standard symbols to represents a newline. Which clearly create a readability problem. In particular when an add-on configuration contains code (python, latex, whatever).

Thus, I wanted to have the right to have newlines in strings in json. And when I use the configuration editor, I want to see new lines insteads of \n.

Usage

This add-on allow you to write new line in your string. The add-on will replace them by "\n" before json load the configuration. This works both for configuration in the file meta.json, and for the the add-on manager's configuration editor.

Warning

Note that it will not put newlines in the configuration written in meta.conf. Indeed, this would create at least two problems:

  • We can't control the order in which add-ons are loaded. Thus all add-ons loaded before this current add-on would fail when trying to read their configuration.
  • If you decide to uninstall this add-on, no configuration with new lines could be read anymore. (In particular, this would happen if you synchronize your configuration using another add-on).

Internal

This add-on has an effect on ALL json strings read by the program. New lines in strings will always be removed and replaced by \n. Thus this add-on may affect more than configurations. However, this add-on call the standard json.loads() function, thus even another add-on affecting json.loads() should still be compatible with the current addon. Futhermore, this add-on has no effect on valid json. Thus the potential change would only be that some invalid json would be accepted, it seems harmless.

Furthermore, this add-on change ConfigEditor.updateText in module aqt.addons. It does not call the previous function, thus the current add-on will be incompatible with another add-on changing this method.

Links, licence and credits

Key Value
Copyright Arthur Milchior arthur@milchior.fr
Based on Anki code by Damien Elmes anki@ichi2.net
License GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
Source in https://github.com/Arthur-Milchior/anki-json-new-line
Addon number 112201952