| 3824 | }; |
| 3825 | |
| 3826 | static String _process_doc_line(const String &p_line, const String &p_text, const String &p_space_prefix, DocLineState &r_state) { |
| 3827 | String line = p_line; |
| 3828 | if (r_state == DOC_LINE_NORMAL) { |
| 3829 | line = line.strip_edges(true, false); |
| 3830 | } else { |
| 3831 | line = line.trim_prefix(p_space_prefix); |
| 3832 | } |
| 3833 | |
| 3834 | String line_join; |
| 3835 | if (!p_text.is_empty()) { |
| 3836 | if (r_state == DOC_LINE_NORMAL) { |
| 3837 | if (p_text.ends_with("[/codeblock]")) { |
| 3838 | line_join = "\n"; |
| 3839 | } else if (!p_text.ends_with("[br]")) { |
| 3840 | line_join = " "; |
| 3841 | } |
| 3842 | } else { |
| 3843 | line_join = "\n"; |
| 3844 | } |
| 3845 | } |
| 3846 | |
| 3847 | String result; |
| 3848 | int from = 0; |
| 3849 | int buffer_start = 0; |
| 3850 | const int len = line.length(); |
| 3851 | bool process = true; |
| 3852 | while (process) { |
| 3853 | switch (r_state) { |
| 3854 | case DOC_LINE_NORMAL: { |
| 3855 | int lb_pos = line.find_char('[', from); |
| 3856 | if (lb_pos < 0) { |
| 3857 | process = false; |
| 3858 | break; |
| 3859 | } |
| 3860 | int rb_pos = line.find_char(']', lb_pos + 1); |
| 3861 | if (rb_pos < 0) { |
| 3862 | process = false; |
| 3863 | break; |
| 3864 | } |
| 3865 | |
| 3866 | from = rb_pos + 1; |
| 3867 | |
| 3868 | String tag = line.substr(lb_pos + 1, rb_pos - lb_pos - 1); |
| 3869 | if (tag == "code" || tag.begins_with("code ")) { |
| 3870 | r_state = DOC_LINE_IN_CODE; |
| 3871 | } else if (tag == "codeblock" || tag.begins_with("codeblock ")) { |
| 3872 | if (lb_pos == 0) { |
| 3873 | line_join = "\n"; |
| 3874 | } else { |
| 3875 | result += line.substr(buffer_start, lb_pos - buffer_start) + '\n'; |
| 3876 | } |
| 3877 | result += "[" + tag + "]"; |
| 3878 | if (from < len) { |
| 3879 | result += '\n'; |
| 3880 | } |
| 3881 | |
| 3882 | r_state = DOC_LINE_IN_CODEBLOCK; |
| 3883 | buffer_start = from; |
no test coverage detected