qulogic/talkatu

Add some additional tags for rendering more complex documents in pidgin
/*
* talkatu
* Copyright (C) 2017-2018 Gary Kramlich <grim@reaperworld.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
*/
#include "talkatu/talkatuactiongroup.h"
#include "talkatu/talkatutag.h"
/**
* SECTION:talkatutag
* @Title: Tags
* @Short_description: Helpers for handling tags.
*
* Talkatu deals with a lot of tags which this API tries to make easier.
*/
/**
* TALKATU_TAG_PREFIX:
*
* The prefix that all talkatu tags use.
*/
/**
* TALKATU_TAG_PREFIX_LEN:
*
* The length of #TALKATU_TAG_PREFIX for easy computation.
*/
/**
* TALKATU_TAG_BOLD:
*
* A constant that represents the bold font style.
*/
/**
* TALKATU_TAG_ITALIC:
*
* A constant that represents the italic font style.
*/
/**
* TALKATU_TAG_UNDERLINE:
*
* A constant that represents the underlined font style.
*/
/**
* TALKATU_TAG_STRIKETHROUGH:
*
* A constant that represents the strike through font style.
*/
/**
* TALKATU_TAG_SUBSCRIPT:
*
* A constant that represents the sub-script font style.
*/
/**
* TALKATU_TAG_SUPERSCRIPT:
*
* A constant that represents the super-script font style.
*/
/**
* TALKATU_TAG_PRE:
*
* A constant that represents a pre formatted font style.
*/
/**
* TALKATU_TAG_CODE:
*
* A constant that represents a code font style.
*/
/**
* TALKATU_TAG_SEARCH:
*
* A constant that represents the highlighed search term font style.
*/
/**
* TALKATU_TAG_ANCHOR:
*
* A constant that represents an anchor or link font style.
*/
/**
* TALKATU_TAG_H1:
*
* A constant that represents the h1 header font style.
*/
/**
* TALKATU_TAG_H2:
*
* A constant that represents the h2 header font style.
*/
/**
* TALKATU_TAG_H3:
*
* A constant that represents the h3 header font style.
*/
/**
* TALKATU_TAG_H4:
*
* A constant that represents the h4 header font style.
*/
/**
* TALKATU_TAG_H5:
*
* A constant that represents the h5 header font style.
*/
/**
* TALKATU_TAG_H6:
*
* A constant that represents the h6 header font style.
*/
/**
* talkatu_tag_name_for_action_name:
* @action_name: The name of the action to find a tag name for.
*
* Gets the tag name that should be used for @action_name.
*
* Returns: The tag name to be used for @action_name, or %NULL.
*/
const gchar *
talkatu_tag_name_for_action_name(const gchar *action_name) {
if(g_ascii_strcasecmp(action_name, TALKATU_ACTION_FORMAT_BOLD) == 0) {
return TALKATU_TAG_BOLD;
} else if(g_ascii_strcasecmp(action_name, TALKATU_ACTION_FORMAT_ITALIC) == 0) {
return TALKATU_TAG_ITALIC;
} else if(g_ascii_strcasecmp(action_name, TALKATU_ACTION_FORMAT_UNDERLINE) == 0) {
return TALKATU_TAG_UNDERLINE;
} else if(g_ascii_strcasecmp(action_name, TALKATU_ACTION_FORMAT_STRIKETHROUGH) == 0) {
return TALKATU_TAG_STRIKETHROUGH;
}
return NULL;
}
/**
* talkatu_tag_name_to_html:
* @tag_name: The name of the tag.
*
* Determines the HTML tag for @tag_name.
*
* Returns: The HTML tag if any for @tag_name.
*/
const gchar *
talkatu_tag_name_to_html(const gchar *tag_name) {
if(tag_name == NULL) {
return NULL;
}
if(g_ascii_strncasecmp(TALKATU_TAG_PREFIX, tag_name, TALKATU_TAG_PREFIX_LEN) != 0) {
return NULL;
}
if(g_ascii_strcasecmp(tag_name, TALKATU_TAG_BOLD) == 0) {
return "b";
} else if(g_ascii_strcasecmp(tag_name, TALKATU_TAG_ITALIC) == 0) {
return "i";
} else if(g_ascii_strcasecmp(tag_name, TALKATU_TAG_UNDERLINE) == 0) {
return "u";
} else if(g_ascii_strcasecmp(tag_name, TALKATU_TAG_STRIKETHROUGH) == 0) {
return "s";
} else if(g_ascii_strcasecmp(tag_name, TALKATU_TAG_SUBSCRIPT) == 0) {
return "sub";
} else if(g_ascii_strcasecmp(tag_name, TALKATU_TAG_SUPERSCRIPT) == 0) {
return "sup";
} else if(g_ascii_strcasecmp(tag_name, TALKATU_TAG_PRE) == 0) {
return "pre";
} else if(g_ascii_strcasecmp(tag_name, TALKATU_TAG_H1) == 0) {
return "h1";
} else if(g_ascii_strcasecmp(tag_name, TALKATU_TAG_H2) == 0) {
return "h2";
} else if(g_ascii_strcasecmp(tag_name, TALKATU_TAG_H3) == 0) {
return "h3";
} else if(g_ascii_strcasecmp(tag_name, TALKATU_TAG_H4) == 0) {
return "h4";
} else if(g_ascii_strcasecmp(tag_name, TALKATU_TAG_H5) == 0) {
return "h5";
} else if(g_ascii_strcasecmp(tag_name, TALKATU_TAG_H6) == 0) {
return "h6";
} else if(g_ascii_strcasecmp(tag_name, TALKATU_TAG_ANCHOR) == 0) {
return "a";
} else if(g_ascii_strcasecmp(tag_name, TALKATU_TAG_DL) == 0) {
return "dl";
} else if(g_ascii_strcasecmp(tag_name, TALKATU_TAG_DT) == 0) {
return "dt";
} else if(g_ascii_strcasecmp(tag_name, TALKATU_TAG_DD) == 0) {
return "dd";
}
return NULL;
}