From b75d7976cfe8db43783b930c1f4774f2ad4936f5 Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Thu, 6 Oct 2022 11:43:26 +0200 Subject: Add support for HTML 4 character references in JSX attributes --- src/to_html.rs | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) (limited to 'src/to_html.rs') diff --git a/src/to_html.rs b/src/to_html.rs index d7d054d..814f7cf 100644 --- a/src/to_html.rs +++ b/src/to_html.rs @@ -2,8 +2,8 @@ use crate::event::{Event, Kind, Name}; use crate::mdast::AlignKind; use crate::util::{ + character_reference::decode as decode_character_reference, constant::{SAFE_PROTOCOL_HREF, SAFE_PROTOCOL_SRC}, - decode_character_reference::{decode_named, decode_numeric}, encode::encode, gfm_tagfilter::gfm_tagfilter, infer::{gfm_table_align, list_loose}, @@ -783,14 +783,8 @@ fn on_exit_character_reference_value(context: &mut CompileContext) { context.bytes, &Position::from_exit_event(context.events, context.index), ); - let value = slice.as_str(); - - let value = match marker { - b'#' => decode_numeric(value, 10), - b'x' => decode_numeric(value, 16), - b'&' => decode_named(value), - _ => panic!("impossible"), - }; + let value = decode_character_reference(slice.as_str(), marker, true) + .expect("expected to parse only valid named references"); context.push(&encode(&value, context.encode_html)); } -- cgit