Add a prefix to footnote IDs.
This avoids a conflict with multiple blog posts rendering in the same stream.
This commit is contained in:
@@ -44,14 +44,22 @@ impl IRealFootnoteDefinition {
|
||||
/// Get an ID to refer to the first reference to this footnote definition.
|
||||
///
|
||||
/// This ID could, for example, be used for the id attribute in HTML for the reference anchor tag.
|
||||
pub(crate) fn get_reference_id(&self) -> String {
|
||||
format!("fnr.{}", self.get_display_label())
|
||||
pub(crate) fn get_reference_id(&self, id_addition: Option<&str>) -> String {
|
||||
let id_addition = id_addition
|
||||
.map(|id_addition| format!("sec{}.", id_addition))
|
||||
.unwrap_or(String::default());
|
||||
|
||||
format!("{}fnr.{}", id_addition, self.get_display_label())
|
||||
}
|
||||
|
||||
/// Get an ID to refer to the footnote definition.
|
||||
///
|
||||
/// This ID could, for example, be used for the id attribute in HTML for the definition anchor tag.
|
||||
pub(crate) fn get_definition_id(&self) -> String {
|
||||
format!("fn.{}", self.get_display_label())
|
||||
pub(crate) fn get_definition_id(&self, id_addition: Option<&str>) -> String {
|
||||
let id_addition = id_addition
|
||||
.map(|id_addition| format!("sec{}.", id_addition))
|
||||
.unwrap_or(String::default());
|
||||
|
||||
format!("{}fn.{}", id_addition, self.get_display_label())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,20 +32,28 @@ impl IFootnoteReference {
|
||||
/// Get an ID to refer to this footnote reference.
|
||||
///
|
||||
/// This ID could, for example, be used for the id attribute in HTML for the reference anchor tag.
|
||||
pub(crate) fn get_reference_id(&self) -> String {
|
||||
pub(crate) fn get_reference_id(&self, id_addition: Option<&str>) -> String {
|
||||
let id_addition = id_addition
|
||||
.map(|id_addition| format!("sec{}.", id_addition))
|
||||
.unwrap_or(String::default());
|
||||
|
||||
if self.duplicate_offset == 0 {
|
||||
format!("fnr.{}", self.get_display_label())
|
||||
format!("{}fnr.{}", id_addition, self.get_display_label())
|
||||
} else {
|
||||
// Org-mode makes all duplicates use "100" but I figure there is no harm in giving each a unique ID.
|
||||
let append = 100 + self.duplicate_offset - 1;
|
||||
format!("fnr.{}.{}", self.get_display_label(), append)
|
||||
format!("{}fnr.{}.{}", id_addition, self.get_display_label(), append)
|
||||
}
|
||||
}
|
||||
|
||||
/// Get an ID to refer to the footnote definition this footnote reference references.
|
||||
///
|
||||
/// This ID could, for example, be used for the id attribute in HTML for the definition anchor tag.
|
||||
pub(crate) fn get_definition_id(&self) -> String {
|
||||
format!("fn.{}", self.get_display_label())
|
||||
pub(crate) fn get_definition_id(&self, id_addition: Option<&str>) -> String {
|
||||
let id_addition = id_addition
|
||||
.map(|id_addition| format!("sec{}.", id_addition))
|
||||
.unwrap_or(String::default());
|
||||
|
||||
format!("{}fn.{}", id_addition, self.get_display_label())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user