@@ -71,22 +71,22 @@ defmodule ExDoc.DocAST do
7171 The optional `fun` argument allows post-processing each AST node
7272 after it's been converted to markdown.
7373 """
74- def to_markdown_string ( ast , fun \\ fn _ast , string -> string end )
74+ def to_markdown ( ast , fun \\ fn _ast , string -> string end )
7575
76- def to_markdown_string ( binary , _fun ) when is_binary ( binary ) do
76+ def to_markdown ( binary , _fun ) when is_binary ( binary ) do
7777 ExDoc.Utils . h ( binary )
7878 end
7979
80- def to_markdown_string ( list , fun ) when is_list ( list ) do
81- result = Enum . map_join ( list , "" , & to_markdown_string ( & 1 , fun ) )
80+ def to_markdown ( list , fun ) when is_list ( list ) do
81+ result = Enum . map_join ( list , "" , & to_markdown ( & 1 , fun ) )
8282 fun . ( list , result )
8383 end
8484
85- def to_markdown_string ( { :comment , _attrs , inner , _meta } = ast , fun ) do
85+ def to_markdown ( { :comment , _attrs , inner , _meta } = ast , fun ) do
8686 fun . ( ast , "<!--#{ inner } -->" )
8787 end
8888
89- def to_markdown_string ( { :code , attrs , inner , _meta } = ast , fun ) do
89+ def to_markdown ( { :code , attrs , inner , _meta } = ast , fun ) do
9090 lang = attrs [ :class ] || ""
9191
9292 result = """
@@ -98,44 +98,50 @@ defmodule ExDoc.DocAST do
9898 fun . ( ast , result )
9999 end
100100
101- def to_markdown_string ( { :a , attrs , inner , _meta } = ast , fun ) do
102- result = "[#{ to_markdown_string ( inner , fun ) } ](#{ attrs [ :href ] } )"
101+ def to_markdown ( { :a , attrs , inner , _meta } = ast , fun ) do
102+ result = "[#{ to_markdown ( inner , fun ) } ](#{ attrs [ :href ] } )"
103103 fun . ( ast , result )
104104 end
105105
106- def to_markdown_string ( { :hr , _attrs , _inner , _meta } = ast , fun ) do
106+ def to_markdown ( { :hr , _attrs , _inner , _meta } = ast , fun ) do
107107 result = "\n \n ---\n \n "
108108 fun . ( ast , result )
109109 end
110110
111- def to_markdown_string ( { tag , _attrs , _inner , _meta } = ast , fun ) when tag in [ :p , :br ] do
111+ def to_markdown ( { :p , _attrs , inner , _meta } = ast , fun ) do
112+ result = to_markdown ( inner , fun ) <> "\n \n "
113+ fun . ( ast , result )
114+ end
115+
116+ def to_markdown ( { :br , _attrs , _inner , _meta } = ast , fun ) do
112117 result = "\n \n "
113118 fun . ( ast , result )
114119 end
115120
116- def to_markdown_string ( { :img , attrs , _inner , _meta } = ast , fun ) do
121+ def to_markdown ( { :img , attrs , _inner , _meta } = ast , fun ) do
117122 alt = attrs [ :alt ] || ""
118123 title = attrs [ :title ] || ""
119124 result = ""
120125 fun . ( ast , result )
121126 end
122127
123128 # ignoring these: area base col command embed input keygen link meta param source track wbr
124- def to_markdown_string ( { tag , _attrs , _inner , _meta } = ast , fun ) when tag in @ void_elements do
129+ def to_markdown ( { tag , _attrs , _inner , _meta } = ast , fun ) when tag in @ void_elements do
125130 result = ""
126131 fun . ( ast , result )
127132 end
128133
129- def to_markdown_string ( { _tag , _attrs , inner , % { verbatim: true } } = ast , fun ) do
134+ def to_markdown ( { _tag , _attrs , inner , % { verbatim: true } } = ast , fun ) do
130135 result = Enum . join ( inner , "" )
131136 fun . ( ast , result )
132137 end
133138
134- def to_markdown_string ( { _tag , _attrs , inner , _meta } = ast , fun ) do
135- result = to_markdown_string ( inner , fun )
139+ def to_markdown ( { _tag , _attrs , inner , _meta } = ast , fun ) do
140+ result = to_markdown ( inner , fun )
136141 fun . ( ast , result )
137142 end
138143
144+
139145 ## parse markdown
140146
141147 defp parse_markdown ( markdown , opts ) do
0 commit comments