Differences From
Artifact [940c3efd41]:
1 1 -- [ʞ] cortav.lua
2 2 -- ~ lexi hale <lexi@hale.su>
3 3 -- © AGPLv3
4 4 -- ? reference implementation of the cortav document language
5 +--
6 +-- ! TODO refactor encoding logic. it's a complete
7 +-- mess and i seem to have repeatedly gotten
8 +-- confused about how it's supposed to work.
9 +-- the whole shitshow needs to be replaced
10 +-- with a clean, simple paradigm: documents
11 +-- are translated to UTF8 on the way in, and
12 +-- translate back out on the way out. trying
13 +-- to cope with multiple simultaneous
14 +-- encodings in memory is a disaster zone.
5 15
6 16 local ss = require 'sirsem'
7 17 -- aliases for commonly used sirsem funcs
8 18 local startswith = ss.str.begins
9 19 local dump = ss.dump
10 20 local declare = ss.declare
11 21
................................................................................
732 742 spans = {{
733 743 kind = 'raw';
734 744 spans = {str};
735 745 origin = o;
736 746 }};
737 747 origin = o;
738 748 }
749 + end
750 + local function unicodepoint(s,c)
751 + local cp = tonumber(s, 16)
752 + return {
753 + kind = 'codepoint';
754 + code = cp;
755 + }
739 756 end
740 757 ct.spanctls = {
741 758 {seq = '!', parse = formatter 'emph'};
742 759 {seq = '*', parse = formatter 'strong'};
743 760 {seq = '~', parse = formatter 'strike'};
744 761 {seq = '+', parse = formatter 'insert'};
745 762 {seq = '\\', parse = function(s, c) -- raw
................................................................................
794 811 }
795 812 end};
796 813 {seq = '>', parse = insert_link};
797 814 {seq = '→', parse = insert_link};
798 815 {seq = '🔗', parse = insert_link};
799 816 {seq = '##', parse = insert_var_ref(true)};
800 817 {seq = '#', parse = insert_var_ref(false)};
818 +
819 + {seq = 'U+', parse = unicodepoint};
820 + {seq = 'u+', parse = unicodepoint};
821 + {seq = 'U', parse = unicodepoint};
822 + {seq = 'u', parse = unicodepoint};
823 +
801 824 {seq = '%%', parse = function (s,c)
802 825 local com = s:match '^%%%%%s*(.*)$'
803 826 return {
804 827 kind = 'comment';
805 828 comment = com;
806 829 }
807 830 end};