]> uap-core.de Git - note.git/commitdiff
fix markdown link text generation main
authorOlaf Wintermann <olaf.wintermann@gmail.com>
Tue, 10 Mar 2026 19:52:06 +0000 (20:52 +0100)
committerOlaf Wintermann <olaf.wintermann@gmail.com>
Tue, 10 Mar 2026 19:52:06 +0000 (20:52 +0100)
application/gtk-text.c
application/tests/test-editor.c
application/tests/test-editor.h
application/tests/testmain.c

index b747251c2a24c647a051ccf74682dd48f226d941..003822c3a2fd1889a9ab9f4dba3000b0502ac7e0 100644 (file)
@@ -1263,9 +1263,10 @@ cxmutstr editor_get_markdown(UiText *text, const CxAllocator *a) {
             }
             if(name[0] == '_') {
                 GtkTextTag *tag = entry->value;
-                link = g_object_get_data(G_OBJECT(tag), "link");
-                if(link) {
+                TextLink *islink = g_object_get_data(G_OBJECT(tag), "link");
+                if(islink) {
                     cxBufferPut(&out, '[');
+                    link = islink;
                 }
             }
         }
index 04e4c54421866b548ca4ac6ff586fad0786596ca..0baadd3021a5187afeb39006e87dea3c42acfd1c 100644 (file)
@@ -488,3 +488,9 @@ CX_TEST(test_editor_load_markdown_span1) {
         CX_TEST_CALL_SUBROUTINE(test_editor_markdown_load_get, cx_mutstr("Text **bold** and _underline_\n\nText *italic*\n"));
     }
 }
+
+CX_TEST(test_editor_load_markdown_link) {
+    CX_TEST_DO {
+        CX_TEST_CALL_SUBROUTINE(test_editor_markdown_load_get, cx_mutstr("Link [link1](https://example.com/link1)\n[link2][1]\n\n[1]: https://example.com/link2"));
+    }
+}
index 5be365340b8cd7c0084ca024a51f333a2a28395e..ba3ba13965d575ffa8fb6f9646ddaa25abe875b2 100644 (file)
@@ -46,6 +46,7 @@ CX_TEST(test_editor_load_markdown_para1);
 CX_TEST(test_editor_load_markdown_heading_para);
 CX_TEST(test_editor_load_markdown_list1);
 CX_TEST(test_editor_load_markdown_span1);
+CX_TEST(test_editor_load_markdown_link);
 
 #ifdef __cplusplus
 }
index 67cfd0351017e7532d8976983bfb8eebb319e97a..13cec75427eeb68d4fd82e4b83921fb6252fe7a9 100644 (file)
@@ -87,6 +87,7 @@ int main(int argc, char **argv) {
     cx_test_register(suite, test_editor_load_markdown_heading_para);
     cx_test_register(suite, test_editor_load_markdown_list1);
     cx_test_register(suite, test_editor_load_markdown_span1);
+    cx_test_register(suite, test_editor_load_markdown_link);
     
     cx_test_register(suite, test_text_search_strcasestr);
     cx_test_register(suite, test_text_search_cs);