Skip to content

Commit

Permalink
add rendering support for SuperMD's $text
Browse files Browse the repository at this point in the history
  • Loading branch information
kristoff-it committed Oct 16, 2024
1 parent f5d7382 commit 3fc3ecc
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
4 changes: 2 additions & 2 deletions build.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
.version = "0.0.0",
.dependencies = .{
.supermd = .{
.url = "git+https://github.com/kristoff-it/supermd#56b5a2e2e306b47531849321b934c3995f52d4dd",
.hash = "1220af0bb7fafca4b0476afee8f1cbe0528824d6f935d4ed04b6c1ea950e24862b2f",
.url = "git+https://github.com/kristoff-it/supermd#d8a6cef01691ddedf7bb52e91065fcbf8191f68d",
.hash = "1220f2a44a5556f91db5938482362da07d790c95560ffd099dbc883a7f0431b275a7",
},
.scripty = .{
.url = "git+https://github.com/kristoff-it/scripty#df8c11380f9e9bec34809f2242fb116d27cf39d6",
Expand Down
2 changes: 1 addition & 1 deletion src/exes/layout/cache.zig
Original file line number Diff line number Diff line change
Expand Up @@ -883,7 +883,7 @@ fn loadPage(
const directive = n.getDirective() orelse continue;

switch (directive.kind) {
.section, .block, .heading => {},
.section, .block, .heading, .text => {},
.code => |code| {
const value = switch (code.src.?) {
else => unreachable,
Expand Down
16 changes: 16 additions & 0 deletions src/render/html.zig
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,22 @@ fn renderDirective(
const directive = node.getDirective() orelse return renderLink(ev, w);
switch (directive.kind) {
.section, .block, .heading => {},
.text => switch (ev.dir) {
.enter => {
try w.print("<span", .{});
if (directive.id) |id| try w.print(" id=\"{s}\"", .{id});
if (directive.attrs) |attrs| {
try w.print(" class=\"", .{});
for (attrs) |attr| try w.print("{s} ", .{attr});
try w.print("\"", .{});
}
if (directive.title) |t| try w.print(" title=\"{s}\"", .{t});
try w.print(">", .{});
},
.exit => {
try w.print("</span>", .{});
},
},
.image => |img| switch (ev.dir) {
.enter => {
const caption = node.firstChild();
Expand Down

0 comments on commit 3fc3ecc

Please sign in to comment.