subroutinehtml_escapepure
pure subroutine html_escape(text, b, quotes)
Append text, escaped for HTML.
Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
| text | character(len=*) | in | the text | |
| b | type(buffer_t) | inout | the buffer | |
| quotes | logical | in | true to escape |
Calls
Called by
- add_words
- argument_table
- badge
- binding_table
- call_text
- code_block_html
- common_sections
- entity_anchor
- entity_title
- ford_link
- graph_heading
- highlight_data
- highlight_fortran
- icon_link
- index_page
- inline_abbreviation
- inline_angle
- inline_backslash
- inline_code
- inline_image
- interface_body
- license_text
- link_to
- list_page
- make_footer
- names_page
- page_head
- page_links
- side_group
- sidebar_script
- signature
- signature_arguments
- site_side
- specific_link
- static_page
- write_form
- write_link
- write_type
Source
Show the code
pure subroutine html_escape(text, b, quotes)
character(len=*), intent(in) :: text !! the text
type(buffer_t), intent(inout) :: b !! the buffer
logical, intent(in) :: quotes !! true to escape `"` as well, for attribute values
integer :: k, start
start = 1
do k = 1, len(text)
select case (text(k:k))
case ('&', '<', '>', '"')
if (text(k:k) == '"' .and. .not. quotes) cycle
if (k > start) call add(b, text(start:k - 1))
start = k + 1
select case (text(k:k))
case ('&'); call add(b, '&')
case ('<'); call add(b, '<')
case ('>'); call add(b, '>')
case default; call add(b, '"')
end select
end select
end do
if (start <= len(text)) call add(b, text(start:))
end subroutine html_escape