コード例 #1
0
ファイル: inlines.c プロジェクト: lowks/cmark.ex
// Assumes the subject has a c at the current position.
static cmark_node* handle_delim(subject* subj, unsigned char c, bool smart)
{
	int numdelims;
	cmark_node * inl_text;
	bool can_open, can_close;
	cmark_chunk contents;

	numdelims = scan_delims(subj, c, &can_open, &can_close);

	if (c == '\'' && smart) {
		contents = cmark_chunk_literal(RIGHTSINGLEQUOTE);
	} else if (c == '"' && smart) {
		contents = cmark_chunk_literal(can_close ? RIGHTDOUBLEQUOTE : LEFTDOUBLEQUOTE);
	} else {
		contents = cmark_chunk_dup(&subj->input, subj->pos - numdelims, numdelims);
	}

	inl_text = make_str(contents);

	if ((can_open || can_close) &&
	    (!(c == '\'' || c == '"') || smart)) {
		push_delimiter(subj, c, can_open, can_close, inl_text);
	}

	return inl_text;
}
コード例 #2
0
// Parse strong/emph or a fallback.
// Assumes the subject has '_' or '*' at the current position.
static cmark_node* handle_strong_emph(subject* subj, unsigned char c)
{
	int numdelims;
	cmark_node * inl_text;
	bool can_open, can_close;

	numdelims = scan_delims(subj, c, &can_open, &can_close);

	inl_text = make_str(cmark_chunk_dup(&subj->input, subj->pos - numdelims, numdelims));

	if (can_open || can_close) {
		push_delimiter(subj, c, can_open, can_close, inl_text);
	}

	return inl_text;
}