-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrender.jl
More file actions
executable file
·50 lines (46 loc) · 1.27 KB
/
render.jl
File metadata and controls
executable file
·50 lines (46 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/home/engon/.julia/juliaup/julia-nightly/bin/julia
using Markdown
function getfilestoconvert()::Channel{String}
Channel{String}() do channel
for (parent, internal, files) in walkdir(".")
length(internal) > 0 && continue
for file in files
if endswith(file, ".md")
push!(channel, joinpath(parent, file))
end
end
end
end
end
function replaceext(path::String, newext::String)::String
first(splitext(path)) * "." * newext
end
function convertfiles()::Channel{String}
Channel{String}() do channel
for file in getfilestoconvert()
try
markdown = Markdown.parse_file(file)
println(markdown)
open(replaceext(file, "html"), "w") do f
print(f, Markdown.html(markdown))
end
open(replaceext(file, "txt"), "w") do f
print(f, Markdown.plain(markdown))
end
push!(channel, file)
catch e
@error "Error processing file: $file" exception = e
end
end
end
end
function (@main)(args::Vector{String})
if length(args) > 0
@warn "Ignoring command line arguments: $args"
end
@info "Starting conversion of Markdown files to HTML..."
for file in convertfiles()
@info "Converted file: $file"
end
@info "Conversion completed."
end