Skip to content

Commit

Permalink
Markdown: Add settings option newline = new paragraph (PR #1260 by @g…
Browse files Browse the repository at this point in the history
…santner)


Closes #1259 , Closes #875 , Closes #516 , Closes #189
  • Loading branch information
gsantner authored Feb 28, 2021
1 parent d7b2a13 commit 748d6f5
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,10 @@ public String convertMarkup(String markup, Context context, boolean isExportInLi
// Notable: They use a home brewed syntax for referencing attachments: @attachment/f.png = ../attachements/f.jpg -- https://github.com/gsantner/markor/issues/1252
markup = markup.replace("](@attachment/", "](../attachements/");

if (appSettings.isMarkdownNewlineNewparagraphEnabled()) {
markup = markup.replace("\n", " \n");
}

////////////
// Markup parsing - afterwards = HTML
converted = flexmarkRenderer.withOptions(options).render(flexmarkParser.parse(markup));
Expand All @@ -220,7 +224,6 @@ public String convertMarkup(String markup, Context context, boolean isExportInLi
}
}


// Deliver result
return putContentIntoTemplate(context, converted, isExportInLightMode, file, onLoadJs, head);
}
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/java/net/gsantner/markor/util/AppSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,10 @@ public boolean isMarkdownMathEnabled() {
return getBool(R.string.pref_key__markdown_render_math, false);
}

public boolean isMarkdownNewlineNewparagraphEnabled() {
return getBool(R.string.pref_key__markdown_newline_newparagraph, false);
}

public boolean isMarkdownTableOfContentsEnabled() {
return getBool(R.string.pref_key__markdown_show_toc, false);
}
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/string-not_translatable.xml
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ work. If not, see <https://creativecommons.org/publicdomain/zero/1.0/>.
<string name="pref_key__inject_to_head" translatable="false">pref_key__inject_to_head</string>
<string name="pref_key__inject_to_body" translatable="false">pref_key__inject_to_body</string>
<string name="pref_key__markdown_render_math" translatable="false">pref_key__markdown_render_math</string>
<string name="pref_key__markdown_newline_newparagraph" translatable="false">pref_key__markdown_newline_newparagraph</string>
<string name="pref_key__markdown_show_toc" translatable="false">pref_key__markdown_show_toc</string>
<string name="pref_key__is_launcher_for_special_files_enabled" translatable="false">pref_key__is_launcher_for_special_files_enabled</string>
<string name="pref_key__editor_basic_color_scheme__bg_light" translatable="false">pref_key__editor_basic_color_scheme__bg_light</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -410,4 +410,5 @@ work. If not, see <https://creativecommons.org/publicdomain/zero/1.0/>.
<string name="replace_all">Replace all</string>
<string name="matches">Matches</string>
<string name="search_replace_pattern_error_message">Search or replace pattern error.</string>
<string name="newline_is_new_paragraph">Newline = new paragraph</string>
</resources>
5 changes: 5 additions & 0 deletions app/src/main/res/xml/preferences_master.xml
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,11 @@
android:key="@string/pref_key__markdown__monospace_some_parts"
android:summary="@string/use_different_fonttype_slow_down"
android:title="@string/use_monospace_for_code" />
<CheckBoxPreference
android:defaultValue="false"
android:icon="@drawable/ic_baseline_keyboard_return_24"
android:key="@string/pref_key__markdown_newline_newparagraph"
android:title="@string/newline_is_new_paragraph" />
<CheckBoxPreference
android:defaultValue="false"
android:icon="@drawable/ic_code_black_24dp"
Expand Down

0 comments on commit 748d6f5

Please sign in to comment.