mirror of
https://github.com/eitchtee/WYGIWYH.git
synced 2026-02-25 08:54:52 +01:00
Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cd7ecd42ea | ||
|
|
0b83ad6b3e | ||
|
|
d0ef08252e | ||
|
|
1140d9c896 | ||
|
|
b2843a1ec1 | ||
|
|
d25aba7be9 | ||
|
|
c3eaca3e9a | ||
|
|
65ad51c273 |
52
app/apps/common/templatetags/markdown.py
Normal file
52
app/apps/common/templatetags/markdown.py
Normal file
@@ -0,0 +1,52 @@
|
||||
from typing import Optional
|
||||
|
||||
import mistune
|
||||
from django import template
|
||||
from django.utils.safestring import mark_safe
|
||||
from mistune import HTMLRenderer, Markdown, BlockParser, InlineParser, safe_entity
|
||||
from mistune.plugins.formatting import strikethrough as plugin_strikethrough
|
||||
from mistune.plugins.url import url as plugin_url
|
||||
|
||||
|
||||
register = template.Library()
|
||||
|
||||
|
||||
class CustomRenderer(HTMLRenderer):
|
||||
def link(self, text: str, url: str, title: Optional[str] = None) -> str:
|
||||
s = '<a rel="nofollow" target="_blank" href="' + self.safe_url(url) + '"'
|
||||
if title:
|
||||
s += ' title="' + safe_entity(title) + '"'
|
||||
return s + ">" + text + "</a>"
|
||||
|
||||
def paragraph(self, text: str) -> str:
|
||||
return text + "\n"
|
||||
|
||||
def softbreak(self) -> str:
|
||||
return "\n"
|
||||
|
||||
def blank_line(self) -> str:
|
||||
return "\n"
|
||||
|
||||
|
||||
block = BlockParser()
|
||||
block.rules = ["blank_line"]
|
||||
inline = InlineParser(hard_wrap=False)
|
||||
inline.rules = [
|
||||
"emphasis",
|
||||
"link",
|
||||
"auto_link",
|
||||
"auto_email",
|
||||
"linebreak",
|
||||
"softbreak",
|
||||
]
|
||||
markdown = Markdown(
|
||||
renderer=CustomRenderer(escape=False),
|
||||
block=block,
|
||||
inline=inline,
|
||||
plugins=[plugin_strikethrough, plugin_url],
|
||||
)
|
||||
|
||||
|
||||
@register.filter(name="limited_markdown")
|
||||
def limited_markdown(value):
|
||||
return mark_safe(markdown(value))
|
||||
@@ -84,9 +84,12 @@ def transactions_list(request, month: int, year: int):
|
||||
"account__group",
|
||||
"category",
|
||||
"tags",
|
||||
"tags__id",
|
||||
"account__exchange_currency",
|
||||
"account__currency",
|
||||
"installment_plan",
|
||||
"entities__name",
|
||||
"entities__id",
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
@@ -336,9 +336,12 @@ def transaction_all_list(request):
|
||||
"account__group",
|
||||
"category",
|
||||
"tags",
|
||||
"tags__id",
|
||||
"account__exchange_currency",
|
||||
"account__currency",
|
||||
"installment_plan",
|
||||
"entities__name",
|
||||
"entities__id",
|
||||
).all()
|
||||
|
||||
transactions = default_order(transactions, order=order)
|
||||
|
||||
@@ -9,8 +9,8 @@ msgstr ""
|
||||
"Project-Id-Version: \n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2025-01-28 00:49+0000\n"
|
||||
"PO-Revision-Date: 2025-01-27 13:27-0300\n"
|
||||
"Last-Translator: Herculino Trotta\n"
|
||||
"PO-Revision-Date: 2025-01-29 06:12+0100\n"
|
||||
"Last-Translator: Dimitri Decrock <dimitri@fam-decrock.eu>\n"
|
||||
"Language-Team: \n"
|
||||
"Language: nl\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
@@ -323,8 +323,6 @@ msgid "Info"
|
||||
msgstr "Info"
|
||||
|
||||
#: apps/common/views.py:110
|
||||
#, fuzzy
|
||||
#| msgid "Category updated successfully"
|
||||
msgid "Cache cleared successfully"
|
||||
msgstr "Categorie succesvol bijgewerkt"
|
||||
|
||||
@@ -1180,7 +1178,7 @@ msgstr "Tijdsnotatie"
|
||||
|
||||
#: apps/users/forms.py:102 apps/users/models.py:48
|
||||
msgid "Number Format"
|
||||
msgstr "Nummerformat"
|
||||
msgstr "Schrijfwijze Nummers"
|
||||
|
||||
#: apps/users/forms.py:131
|
||||
msgid "Save"
|
||||
@@ -1906,8 +1904,6 @@ msgid "Settings"
|
||||
msgstr "Instellingen"
|
||||
|
||||
#: templates/includes/navbar/user_menu.html:38
|
||||
#, fuzzy
|
||||
#| msgid "Clear"
|
||||
msgid "Clear cache"
|
||||
msgstr "Leegmaken"
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
{% load markdown %}
|
||||
{% load i18n %}
|
||||
<div class="transaction d-flex my-1 {% if transaction.type == "EX" %}expense{% else %}income{% endif %}">
|
||||
{% if not disable_selection %}
|
||||
@@ -54,7 +55,7 @@
|
||||
{% if transaction.notes %}
|
||||
<div class="row mb-2 mb-lg-1 tw-text-gray-400">
|
||||
<div class="col-auto pe-1"><i class="fa-solid fa-align-left fa-fw me-1 fa-xs"></i></div>
|
||||
<div class="col ps-0">{{ transaction.notes | linebreaksbr }}</div>
|
||||
<div class="col ps-0">{{ transaction.notes | limited_markdown | linebreaksbr }}</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{# Category#}
|
||||
|
||||
@@ -26,3 +26,4 @@ python-dateutil~=2.9.0.post0
|
||||
simpleeval~=1.0.0
|
||||
pydantic~=2.10.5
|
||||
PyYAML~=6.0.2
|
||||
mistune~=3.1.1
|
||||
|
||||
Reference in New Issue
Block a user