Compare commits
38 Commits
config_fil
...
8.x-1.x
27 changed files with 1656 additions and 180 deletions
@ -0,0 +1,4 @@ |
|||||||
|
Description |
||||||
|
----------- |
||||||
|
|
||||||
|
Example content type and text format to demonstrate a fully-configured Reference Footnotes setup. |
@ -0,0 +1,13 @@ |
|||||||
|
name: 'BibCite Footnotes Article with Citations' |
||||||
|
type: module |
||||||
|
description: 'Example module to show a fully-configured content type and text format with Reference Footnotes.' |
||||||
|
core_version_requirement: ^8 || ^9 || ^10 |
||||||
|
package: 'Bibliography & Citation' |
||||||
|
dependencies: |
||||||
|
- bibcite_footnotees:bibcite_footnotes |
||||||
|
- bibcite:bibcite_import |
||||||
|
- bibcite:bibcite_bibtex |
||||||
|
- bibcite:bibcite_endnote |
||||||
|
- bibcite:bibcite_ris |
||||||
|
- bibcite:bibcite_marc |
||||||
|
- inline_entity_form:inline_entity_form |
@ -0,0 +1,113 @@ |
|||||||
|
langcode: en |
||||||
|
status: true |
||||||
|
dependencies: |
||||||
|
config: |
||||||
|
- field.field.node.bibcite_fn_article_references.body |
||||||
|
- field.field.node.bibcite_fn_article_references.field_bibcite_fn_works_cited |
||||||
|
- field.field.node.bibcite_fn_article_references.field_image |
||||||
|
- field.field.node.bibcite_fn_article_references.field_tags |
||||||
|
- image.style.thumbnail |
||||||
|
- node.type.bibcite_fn_article_references |
||||||
|
module: |
||||||
|
- image |
||||||
|
- inline_entity_form |
||||||
|
- path |
||||||
|
- text |
||||||
|
id: node.bibcite_fn_article_references.default |
||||||
|
targetEntityType: node |
||||||
|
bundle: bibcite_fn_article_references |
||||||
|
mode: default |
||||||
|
content: |
||||||
|
body: |
||||||
|
type: text_textarea_with_summary |
||||||
|
weight: 7 |
||||||
|
settings: |
||||||
|
rows: 9 |
||||||
|
summary_rows: 3 |
||||||
|
placeholder: '' |
||||||
|
third_party_settings: { } |
||||||
|
region: content |
||||||
|
created: |
||||||
|
type: datetime_timestamp |
||||||
|
weight: 2 |
||||||
|
region: content |
||||||
|
settings: { } |
||||||
|
third_party_settings: { } |
||||||
|
field_bibcite_fn_works_cited: |
||||||
|
weight: 8 |
||||||
|
settings: |
||||||
|
form_mode: default |
||||||
|
label_singular: '' |
||||||
|
label_plural: '' |
||||||
|
allow_new: true |
||||||
|
allow_existing: true |
||||||
|
match_operator: CONTAINS |
||||||
|
override_labels: false |
||||||
|
collapsible: false |
||||||
|
collapsed: false |
||||||
|
allow_duplicate: false |
||||||
|
third_party_settings: { } |
||||||
|
type: inline_entity_form_complex |
||||||
|
region: content |
||||||
|
field_image: |
||||||
|
weight: 10 |
||||||
|
settings: |
||||||
|
progress_indicator: throbber |
||||||
|
preview_image_style: thumbnail |
||||||
|
third_party_settings: { } |
||||||
|
type: image_image |
||||||
|
region: content |
||||||
|
field_tags: |
||||||
|
weight: 9 |
||||||
|
settings: |
||||||
|
match_operator: CONTAINS |
||||||
|
size: 60 |
||||||
|
placeholder: '' |
||||||
|
third_party_settings: { } |
||||||
|
type: entity_reference_autocomplete |
||||||
|
region: content |
||||||
|
path: |
||||||
|
type: path |
||||||
|
weight: 5 |
||||||
|
region: content |
||||||
|
settings: { } |
||||||
|
third_party_settings: { } |
||||||
|
promote: |
||||||
|
type: boolean_checkbox |
||||||
|
settings: |
||||||
|
display_label: true |
||||||
|
weight: 3 |
||||||
|
region: content |
||||||
|
third_party_settings: { } |
||||||
|
status: |
||||||
|
type: boolean_checkbox |
||||||
|
settings: |
||||||
|
display_label: true |
||||||
|
weight: 6 |
||||||
|
region: content |
||||||
|
third_party_settings: { } |
||||||
|
sticky: |
||||||
|
type: boolean_checkbox |
||||||
|
settings: |
||||||
|
display_label: true |
||||||
|
weight: 4 |
||||||
|
region: content |
||||||
|
third_party_settings: { } |
||||||
|
title: |
||||||
|
type: string_textfield |
||||||
|
weight: 0 |
||||||
|
region: content |
||||||
|
settings: |
||||||
|
size: 60 |
||||||
|
placeholder: '' |
||||||
|
third_party_settings: { } |
||||||
|
uid: |
||||||
|
type: entity_reference_autocomplete |
||||||
|
weight: 1 |
||||||
|
settings: |
||||||
|
match_operator: CONTAINS |
||||||
|
size: 60 |
||||||
|
placeholder: '' |
||||||
|
region: content |
||||||
|
third_party_settings: { } |
||||||
|
hidden: { } |
@ -0,0 +1,57 @@ |
|||||||
|
langcode: en |
||||||
|
status: true |
||||||
|
dependencies: |
||||||
|
config: |
||||||
|
- field.field.node.bibcite_fn_article_references.body |
||||||
|
- field.field.node.bibcite_fn_article_references.field_bibcite_fn_works_cited |
||||||
|
- field.field.node.bibcite_fn_article_references.field_image |
||||||
|
- field.field.node.bibcite_fn_article_references.field_tags |
||||||
|
- node.type.bibcite_fn_article_references |
||||||
|
module: |
||||||
|
- image |
||||||
|
- text |
||||||
|
- user |
||||||
|
id: node.bibcite_fn_article_references.default |
||||||
|
targetEntityType: node |
||||||
|
bundle: bibcite_fn_article_references |
||||||
|
mode: default |
||||||
|
content: |
||||||
|
body: |
||||||
|
label: hidden |
||||||
|
type: text_default |
||||||
|
weight: 1 |
||||||
|
settings: { } |
||||||
|
third_party_settings: { } |
||||||
|
region: content |
||||||
|
field_bibcite_fn_works_cited: |
||||||
|
weight: 2 |
||||||
|
label: above |
||||||
|
settings: |
||||||
|
view_mode: citation |
||||||
|
link: false |
||||||
|
third_party_settings: { } |
||||||
|
type: entity_reference_entity_view |
||||||
|
region: content |
||||||
|
field_image: |
||||||
|
weight: 4 |
||||||
|
label: above |
||||||
|
settings: |
||||||
|
image_style: '' |
||||||
|
image_link: '' |
||||||
|
third_party_settings: { } |
||||||
|
type: image |
||||||
|
region: content |
||||||
|
field_tags: |
||||||
|
weight: 3 |
||||||
|
label: above |
||||||
|
settings: |
||||||
|
link: true |
||||||
|
third_party_settings: { } |
||||||
|
type: entity_reference_label |
||||||
|
region: content |
||||||
|
links: |
||||||
|
weight: 0 |
||||||
|
region: content |
||||||
|
settings: { } |
||||||
|
third_party_settings: { } |
||||||
|
hidden: { } |
@ -0,0 +1,51 @@ |
|||||||
|
langcode: en |
||||||
|
status: true |
||||||
|
dependencies: |
||||||
|
config: |
||||||
|
- filter.format.basic_html_with_references |
||||||
|
module: |
||||||
|
- ckeditor |
||||||
|
format: basic_html_with_references |
||||||
|
editor: ckeditor |
||||||
|
settings: |
||||||
|
toolbar: |
||||||
|
rows: |
||||||
|
- |
||||||
|
- |
||||||
|
name: Formatting |
||||||
|
items: |
||||||
|
- Bold |
||||||
|
- Italic |
||||||
|
- |
||||||
|
name: Links |
||||||
|
items: |
||||||
|
- DrupalLink |
||||||
|
- DrupalUnlink |
||||||
|
- |
||||||
|
name: Lists |
||||||
|
items: |
||||||
|
- BulletedList |
||||||
|
- NumberedList |
||||||
|
- |
||||||
|
name: Media |
||||||
|
items: |
||||||
|
- Blockquote |
||||||
|
- DrupalImage |
||||||
|
- |
||||||
|
name: Tools |
||||||
|
items: |
||||||
|
- Source |
||||||
|
- reference_footnotes |
||||||
|
plugins: |
||||||
|
stylescombo: |
||||||
|
styles: '' |
||||||
|
language: |
||||||
|
language_list: un |
||||||
|
image_upload: |
||||||
|
status: false |
||||||
|
scheme: public |
||||||
|
directory: inline-images |
||||||
|
max_size: '' |
||||||
|
max_dimensions: |
||||||
|
width: null |
||||||
|
height: null |
@ -0,0 +1,21 @@ |
|||||||
|
langcode: en |
||||||
|
status: true |
||||||
|
dependencies: |
||||||
|
config: |
||||||
|
- field.storage.node.body |
||||||
|
- node.type.bibcite_fn_article_references |
||||||
|
module: |
||||||
|
- text |
||||||
|
id: node.bibcite_fn_article_references.body |
||||||
|
field_name: body |
||||||
|
entity_type: node |
||||||
|
bundle: bibcite_fn_article_references |
||||||
|
label: Body |
||||||
|
description: '' |
||||||
|
required: false |
||||||
|
translatable: true |
||||||
|
default_value: { } |
||||||
|
default_value_callback: '' |
||||||
|
settings: |
||||||
|
display_summary: true |
||||||
|
field_type: text_with_summary |
@ -0,0 +1,98 @@ |
|||||||
|
langcode: en |
||||||
|
status: true |
||||||
|
dependencies: |
||||||
|
config: |
||||||
|
- bibcite_entity.bibcite_reference_type.artwork |
||||||
|
- bibcite_entity.bibcite_reference_type.audiovisual |
||||||
|
- bibcite_entity.bibcite_reference_type.bill |
||||||
|
- bibcite_entity.bibcite_reference_type.book |
||||||
|
- bibcite_entity.bibcite_reference_type.book_chapter |
||||||
|
- bibcite_entity.bibcite_reference_type.broadcast |
||||||
|
- bibcite_entity.bibcite_reference_type.case |
||||||
|
- bibcite_entity.bibcite_reference_type.chart |
||||||
|
- bibcite_entity.bibcite_reference_type.classical |
||||||
|
- bibcite_entity.bibcite_reference_type.conference_paper |
||||||
|
- bibcite_entity.bibcite_reference_type.conference_proceedings |
||||||
|
- bibcite_entity.bibcite_reference_type.database |
||||||
|
- bibcite_entity.bibcite_reference_type.film |
||||||
|
- bibcite_entity.bibcite_reference_type.government_report |
||||||
|
- bibcite_entity.bibcite_reference_type.hearing |
||||||
|
- bibcite_entity.bibcite_reference_type.journal |
||||||
|
- bibcite_entity.bibcite_reference_type.journal_article |
||||||
|
- bibcite_entity.bibcite_reference_type.legal_ruling |
||||||
|
- bibcite_entity.bibcite_reference_type.magazine_article |
||||||
|
- bibcite_entity.bibcite_reference_type.manuscript |
||||||
|
- bibcite_entity.bibcite_reference_type.map |
||||||
|
- bibcite_entity.bibcite_reference_type.miscellaneous |
||||||
|
- bibcite_entity.bibcite_reference_type.miscellaneous_section |
||||||
|
- bibcite_entity.bibcite_reference_type.newspaper_article |
||||||
|
- bibcite_entity.bibcite_reference_type.patent |
||||||
|
- bibcite_entity.bibcite_reference_type.personal |
||||||
|
- bibcite_entity.bibcite_reference_type.presentation |
||||||
|
- bibcite_entity.bibcite_reference_type.report |
||||||
|
- bibcite_entity.bibcite_reference_type.software |
||||||
|
- bibcite_entity.bibcite_reference_type.statute |
||||||
|
- bibcite_entity.bibcite_reference_type.thesis |
||||||
|
- bibcite_entity.bibcite_reference_type.unpublished |
||||||
|
- bibcite_entity.bibcite_reference_type.web_article |
||||||
|
- bibcite_entity.bibcite_reference_type.web_project_page |
||||||
|
- bibcite_entity.bibcite_reference_type.web_service |
||||||
|
- bibcite_entity.bibcite_reference_type.website |
||||||
|
- field.storage.node.field_bibcite_fn_works_cited |
||||||
|
- node.type.bibcite_fn_article_references |
||||||
|
id: node.bibcite_fn_article_references.field_bibcite_fn_works_cited |
||||||
|
field_name: field_bibcite_fn_works_cited |
||||||
|
entity_type: node |
||||||
|
bundle: bibcite_fn_article_references |
||||||
|
label: 'Works Cited' |
||||||
|
description: 'List of works mentioned in this article.' |
||||||
|
required: false |
||||||
|
translatable: true |
||||||
|
default_value: { } |
||||||
|
default_value_callback: '' |
||||||
|
settings: |
||||||
|
handler: 'default:bibcite_reference' |
||||||
|
handler_settings: |
||||||
|
target_bundles: |
||||||
|
artwork: artwork |
||||||
|
audiovisual: audiovisual |
||||||
|
bill: bill |
||||||
|
book: book |
||||||
|
book_chapter: book_chapter |
||||||
|
broadcast: broadcast |
||||||
|
case: case |
||||||
|
chart: chart |
||||||
|
classical: classical |
||||||
|
conference_paper: conference_paper |
||||||
|
conference_proceedings: conference_proceedings |
||||||
|
database: database |
||||||
|
film: film |
||||||
|
government_report: government_report |
||||||
|
hearing: hearing |
||||||
|
journal: journal |
||||||
|
journal_article: journal_article |
||||||
|
legal_ruling: legal_ruling |
||||||
|
magazine_article: magazine_article |
||||||
|
manuscript: manuscript |
||||||
|
map: map |
||||||
|
miscellaneous: miscellaneous |
||||||
|
miscellaneous_section: miscellaneous_section |
||||||
|
newspaper_article: newspaper_article |
||||||
|
patent: patent |
||||||
|
personal: personal |
||||||
|
presentation: presentation |
||||||
|
report: report |
||||||
|
software: software |
||||||
|
statute: statute |
||||||
|
thesis: thesis |
||||||
|
unpublished: unpublished |
||||||
|
web_article: web_article |
||||||
|
web_project_page: web_project_page |
||||||
|
web_service: web_service |
||||||
|
website: website |
||||||
|
sort: |
||||||
|
field: title |
||||||
|
direction: ASC |
||||||
|
auto_create: false |
||||||
|
auto_create_bundle: artwork |
||||||
|
field_type: entity_reference |
@ -0,0 +1,37 @@ |
|||||||
|
langcode: en |
||||||
|
status: true |
||||||
|
dependencies: |
||||||
|
config: |
||||||
|
- field.storage.node.field_image |
||||||
|
- node.type.bibcite_fn_article_references |
||||||
|
module: |
||||||
|
- image |
||||||
|
id: node.bibcite_fn_article_references.field_image |
||||||
|
field_name: field_image |
||||||
|
entity_type: node |
||||||
|
bundle: bibcite_fn_article_references |
||||||
|
label: Image |
||||||
|
description: '' |
||||||
|
required: false |
||||||
|
translatable: true |
||||||
|
default_value: { } |
||||||
|
default_value_callback: '' |
||||||
|
settings: |
||||||
|
file_directory: '[date:custom:Y]-[date:custom:m]' |
||||||
|
file_extensions: 'png gif jpg jpeg' |
||||||
|
max_filesize: '' |
||||||
|
max_resolution: '' |
||||||
|
min_resolution: '' |
||||||
|
alt_field: true |
||||||
|
alt_field_required: true |
||||||
|
title_field: false |
||||||
|
title_field_required: false |
||||||
|
default_image: |
||||||
|
uuid: '' |
||||||
|
alt: '' |
||||||
|
title: '' |
||||||
|
width: null |
||||||
|
height: null |
||||||
|
handler: 'default:file' |
||||||
|
handler_settings: { } |
||||||
|
field_type: image |
@ -0,0 +1,28 @@ |
|||||||
|
langcode: en |
||||||
|
status: true |
||||||
|
dependencies: |
||||||
|
config: |
||||||
|
- field.storage.node.field_tags |
||||||
|
- node.type.bibcite_fn_article_references |
||||||
|
- taxonomy.vocabulary.tags |
||||||
|
id: node.bibcite_fn_article_references.field_tags |
||||||
|
field_name: field_tags |
||||||
|
entity_type: node |
||||||
|
bundle: bibcite_fn_article_references |
||||||
|
label: Tags |
||||||
|
description: 'Enter a comma-separated list. For example: Amsterdam, Mexico City, "Cleveland, Ohio"' |
||||||
|
required: false |
||||||
|
translatable: true |
||||||
|
default_value: { } |
||||||
|
default_value_callback: '' |
||||||
|
settings: |
||||||
|
handler: 'default:taxonomy_term' |
||||||
|
handler_settings: |
||||||
|
target_bundles: |
||||||
|
tags: tags |
||||||
|
sort: |
||||||
|
field: name |
||||||
|
direction: asc |
||||||
|
auto_create: true |
||||||
|
auto_create_bundle: '' |
||||||
|
field_type: entity_reference |
@ -0,0 +1,87 @@ |
|||||||
|
langcode: en |
||||||
|
status: true |
||||||
|
dependencies: |
||||||
|
module: |
||||||
|
- bibcite_footnotes |
||||||
|
- editor |
||||||
|
- footnotes |
||||||
|
name: 'Basic HTML with References' |
||||||
|
format: basic_html_with_references |
||||||
|
weight: 0 |
||||||
|
filters: |
||||||
|
filter_reference_footnotes: |
||||||
|
id: filter_reference_footnotes |
||||||
|
provider: bibcite_footnotes |
||||||
|
status: true |
||||||
|
weight: -50 |
||||||
|
settings: |
||||||
|
footnotes_collapse: '1' |
||||||
|
footnotes_ibid: '0' |
||||||
|
notes_section_label: Notes |
||||||
|
reference_dont_show_backlink_text: '0' |
||||||
|
works_cited_sort_by: alphabetical |
||||||
|
editor_file_reference: |
||||||
|
id: editor_file_reference |
||||||
|
provider: editor |
||||||
|
status: true |
||||||
|
weight: -45 |
||||||
|
settings: { } |
||||||
|
filter_html_image_secure: |
||||||
|
id: filter_html_image_secure |
||||||
|
provider: filter |
||||||
|
status: true |
||||||
|
weight: -46 |
||||||
|
settings: { } |
||||||
|
filter_url: |
||||||
|
id: filter_url |
||||||
|
provider: filter |
||||||
|
status: false |
||||||
|
weight: -41 |
||||||
|
settings: |
||||||
|
filter_url_length: 72 |
||||||
|
filter_html: |
||||||
|
id: filter_html |
||||||
|
provider: filter |
||||||
|
status: true |
||||||
|
weight: -49 |
||||||
|
settings: |
||||||
|
allowed_html: '<a href hreflang id class="" title> <div id class=""> <em> <strong> <cite> <blockquote cite> <code> <ul type class=""> <ol id type class=""> <li id class=""> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id> <span id class=""> <sup> <img src alt data-entity-type data-entity-uuid data-align data-caption> <p> <fn id>' |
||||||
|
filter_html_help: true |
||||||
|
filter_html_nofollow: false |
||||||
|
filter_autop: |
||||||
|
id: filter_autop |
||||||
|
provider: filter |
||||||
|
status: false |
||||||
|
weight: -42 |
||||||
|
settings: { } |
||||||
|
filter_align: |
||||||
|
id: filter_align |
||||||
|
provider: filter |
||||||
|
status: true |
||||||
|
weight: -48 |
||||||
|
settings: { } |
||||||
|
filter_caption: |
||||||
|
id: filter_caption |
||||||
|
provider: filter |
||||||
|
status: true |
||||||
|
weight: -47 |
||||||
|
settings: { } |
||||||
|
filter_htmlcorrector: |
||||||
|
id: filter_htmlcorrector |
||||||
|
provider: filter |
||||||
|
status: false |
||||||
|
weight: -40 |
||||||
|
settings: { } |
||||||
|
filter_html_escape: |
||||||
|
id: filter_html_escape |
||||||
|
provider: filter |
||||||
|
status: false |
||||||
|
weight: -43 |
||||||
|
settings: { } |
||||||
|
filter_footnotes: |
||||||
|
id: filter_footnotes |
||||||
|
provider: footnotes |
||||||
|
status: false |
||||||
|
weight: -44 |
||||||
|
settings: |
||||||
|
footnotes_collapse: '0' |
@ -0,0 +1,17 @@ |
|||||||
|
langcode: en |
||||||
|
status: true |
||||||
|
dependencies: |
||||||
|
module: |
||||||
|
- menu_ui |
||||||
|
third_party_settings: |
||||||
|
menu_ui: |
||||||
|
available_menus: |
||||||
|
- main |
||||||
|
parent: 'main:' |
||||||
|
name: 'Article with References' |
||||||
|
type: bibcite_fn_article_references |
||||||
|
description: 'Article that includes a Works Cited field and in-text references.' |
||||||
|
help: '' |
||||||
|
new_revision: true |
||||||
|
preview_mode: 1 |
||||||
|
display_submitted: true |
@ -0,0 +1,23 @@ |
|||||||
|
{ |
||||||
|
"name": "roblib/bibcite_footnotes", |
||||||
|
"description": "Add citation footnotes with automatic numbering.", |
||||||
|
"type": "drupal-module", |
||||||
|
"homepage": "https://drupal.org/project/bibcite_footnotes", |
||||||
|
"authors": [ |
||||||
|
{ |
||||||
|
"name": "Alexander O'Neill (alxp)", |
||||||
|
"homepage": "https://www.drupal.org/u/alxp", |
||||||
|
"role": "Maintainer" |
||||||
|
} |
||||||
|
], |
||||||
|
"support": { |
||||||
|
"issues": "https://drupal.org/project/issues/bibcite_footnotes", |
||||||
|
"source": "https://cgit.drupalcode.org/bibcite_footnotes" |
||||||
|
}, |
||||||
|
"license": "GPL-2.0+", |
||||||
|
"minimum-stability": "dev", |
||||||
|
"require": { |
||||||
|
"drupal/core": ">=8.6", |
||||||
|
"drupal/fakeobjects": "^1.0" |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,24 @@ |
|||||||
|
langcode: en |
||||||
|
status: true |
||||||
|
dependencies: |
||||||
|
module: |
||||||
|
- bibcite_entity |
||||||
|
- node |
||||||
|
third_party_settings: |
||||||
|
field_permissions: |
||||||
|
permission_type: public |
||||||
|
_core: |
||||||
|
default_config_hash: pxSiuPskUjLuu_0TFIFVYFyZtkIelIPBysbXt_LyLVk |
||||||
|
id: node.field_bibcite_fn_works_cited |
||||||
|
field_name: field_bibcite_fn_works_cited |
||||||
|
entity_type: node |
||||||
|
type: entity_reference |
||||||
|
settings: |
||||||
|
target_type: bibcite_reference |
||||||
|
module: core |
||||||
|
locked: false |
||||||
|
cardinality: -1 |
||||||
|
translatable: true |
||||||
|
indexes: { } |
||||||
|
persist_with_no_fields: false |
||||||
|
custom_storage: false |
@ -1,8 +1,95 @@ |
|||||||
|
|
||||||
.footnotes .footnote .footnote-link { |
.footnote-list .footnotes .footnote-link, |
||||||
|
.footnote-list .footnotes .footnote-multi { |
||||||
float: left; |
float: left; |
||||||
} |
} |
||||||
.footnotes .footnote .footnote-link::after { |
.footnote-list .footnotes .footnote-link::after, |
||||||
|
.footnote-list .footnotes .footnote-multi::after { |
||||||
content: " "; |
content: " "; |
||||||
white-space: pre; |
white-space: pre; |
||||||
} |
} |
||||||
|
|
||||||
|
/* |
||||||
|
* CSS specific to Bibcite Footnotes module. |
||||||
|
* (Borrowed from Footnotes module. |
||||||
|
* |
||||||
|
* |
||||||
|
* Thanks to binford2k@lug.wsu.edu for this tip and drinkypoo |
||||||
|
* for the question leading up to it. http://drupal.org/node/80538 |
||||||
|
*/ |
||||||
|
|
||||||
|
/* Add empty space before footnotes and a black line on top. */ |
||||||
|
.footnotes { |
||||||
|
clear: both; |
||||||
|
margin-top: 4em; |
||||||
|
margin-bottom: 2em; |
||||||
|
border-top: 1px solid #000; |
||||||
|
} |
||||||
|
/* Make footnotes appear in a smaller font */ |
||||||
|
.footnotes { |
||||||
|
font-size: 0.9em; |
||||||
|
} |
||||||
|
/* |
||||||
|
Make the footnote a supertext^1 |
||||||
|
*/ |
||||||
|
.see-footnote { |
||||||
|
vertical-align: top; |
||||||
|
position: relative; |
||||||
|
top: -0.25em; |
||||||
|
font-size: 0.9em; |
||||||
|
} |
||||||
|
/* Hide the bullet of the UL list of footnotes */ |
||||||
|
|
||||||
|
ul.footnotes { |
||||||
|
list-style-type: none; |
||||||
|
margin-left: 0; |
||||||
|
padding-left: 0; |
||||||
|
} |
||||||
|
ul.footnotes li { |
||||||
|
margin-left: 2.5em; |
||||||
|
list-style-type: none; |
||||||
|
background: none; /* Garland theme sets a bullet via background image, this must be unset! See bug 861634 */ |
||||||
|
} |
||||||
|
/* Move the footnote number outside of the margin for footnote text (hanging indent) */ |
||||||
|
ul.footnotes { |
||||||
|
/* This is apparently very needed for the "position: absolute;" below to work correctly */ |
||||||
|
position: relative; |
||||||
|
} |
||||||
|
.footnotes .footnote-label { |
||||||
|
position: absolute; |
||||||
|
left: 0; |
||||||
|
z-index: 2; |
||||||
|
} |
||||||
|
/* Highlight the target footnote (or ref number, if a backlink was used) when user clicks a footnote. */ |
||||||
|
.see-footnote:target, |
||||||
|
.footnotes .footnote:target { |
||||||
|
background-color: #eee; |
||||||
|
} |
||||||
|
.see-footnote:target { |
||||||
|
border: solid 1px #aaa; |
||||||
|
} |
||||||
|
/* Note: This CSS has a minor bug on all versions of IE in that the footnote numbers |
||||||
|
are aligned with the absolute bottom of their space, thus being a couple of pixels |
||||||
|
lower than their corresponding line of text. IE5.5 has a serious bug in that the numbers |
||||||
|
are not shifted left at all, thus being garbled together with the start of their text. */ |
||||||
|
|
||||||
|
/* |
||||||
|
Make the multiple backlinks a supertext^1 |
||||||
|
*/ |
||||||
|
.footnotes .footnote-multi { |
||||||
|
vertical-align: top; |
||||||
|
position: relative; |
||||||
|
top: -0.25em; |
||||||
|
font-size: 0.75em; |
||||||
|
} |
||||||
|
/* |
||||||
|
* Textile Footnotes |
||||||
|
*/ |
||||||
|
/* First footnote */ |
||||||
|
#fn1 { |
||||||
|
border-top: 1px solid #000; |
||||||
|
margin-top: 3em; |
||||||
|
} |
||||||
|
.footnote { |
||||||
|
font-size: 0.9em; |
||||||
|
} |
||||||
|
@ -0,0 +1,28 @@ |
|||||||
|
/** |
||||||
|
* @file |
||||||
|
* Provides JavaScript additions to entity embed dialog. |
||||||
|
* |
||||||
|
* This file provides popup windows for previewing embedded entities from the |
||||||
|
* embed dialog. |
||||||
|
*/ |
||||||
|
|
||||||
|
(function ($, Drupal) { |
||||||
|
|
||||||
|
"use strict"; |
||||||
|
|
||||||
|
Drupal.behaviors.bibciteFootnotesReplaceCitations = { |
||||||
|
attach: function attach(context, settings) { |
||||||
|
/* |
||||||
|
if (CKEDITOR.instances) { |
||||||
|
for (var instance in CKEDITOR.instances) { |
||||||
|
var editor = CKEDITOR.instances[instance]; |
||||||
|
var config = editor.config; |
||||||
|
var name = editor.name; |
||||||
|
editor.destroy(); |
||||||
|
CKEDITOR.replace(name, config); |
||||||
|
} |
||||||
|
} |
||||||
|
*/ |
||||||
|
} |
||||||
|
} |
||||||
|
})(jQuery, Drupal); |
@ -0,0 +1,24 @@ |
|||||||
|
<?php |
||||||
|
/** |
||||||
|
* Created by PhpStorm. |
||||||
|
* User: aoneill |
||||||
|
* Date: 2018-10-30 |
||||||
|
* Time: 2:36 PM |
||||||
|
*/ |
||||||
|
|
||||||
|
namespace Drupal\bibcite_footnotes; |
||||||
|
|
||||||
|
|
||||||
|
class CitationTools { |
||||||
|
|
||||||
|
public function getRenderableReference($reference_entity) { |
||||||
|
if (is_numeric($reference_entity)) { |
||||||
|
$reference_entity = \Drupal::entityTypeManager() |
||||||
|
->getStorage('bibcite_reference') |
||||||
|
->load($reference_entity); |
||||||
|
} |
||||||
|
$serializer = \Drupal::service('serializer'); |
||||||
|
$data = $serializer->normalize($reference_entity, 'csl'); |
||||||
|
return ['#theme' => 'bibcite_citation', '#data' => $data]; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,73 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace Drupal\bibcite_footnotes\Plugin\BibCiteProcessor; |
||||||
|
|
||||||
|
use AcademicPuma\CiteProc\CiteProc; |
||||||
|
use Drupal\Core\Config\ConfigFactoryInterface; |
||||||
|
use Drupal\Core\Plugin\ContainerFactoryPluginInterface; |
||||||
|
use Drupal\bibcite\Plugin\BibCiteProcessorBase; |
||||||
|
use Drupal\bibcite\Plugin\BibCiteProcessorInterface; |
||||||
|
use Symfony\Component\DependencyInjection\ContainerInterface; |
||||||
|
|
||||||
|
/** |
||||||
|
* Defines a style provider based on citeproc-php library. |
||||||
|
* |
||||||
|
* Extended to support inline citation links based on the CSL. |
||||||
|
* |
||||||
|
* @BibCiteProcessor( |
||||||
|
* id = "citeproc-php", |
||||||
|
* label = @Translation("Citeproc PHP"), |
||||||
|
* ) |
||||||
|
*/ |
||||||
|
class CiteprocPhpInline extends BibCiteProcessorBase implements BibCiteProcessorInterface, ContainerFactoryPluginInterface { |
||||||
|
|
||||||
|
/** |
||||||
|
* Config factory service. |
||||||
|
* |
||||||
|
* @var \Drupal\Core\Config\ConfigFactoryInterface |
||||||
|
*/ |
||||||
|
protected $configFactory; |
||||||
|
|
||||||
|
/** |
||||||
|
* {@inheritdoc} |
||||||
|
*/ |
||||||
|
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { |
||||||
|
return new static( |
||||||
|
$configuration, |
||||||
|
$plugin_id, |
||||||
|
$plugin_definition, |
||||||
|
$container->get('config.factory') |
||||||
|
); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* {@inheritdoc} |
||||||
|
*/ |
||||||
|
public function __construct(array $configuration, $plugin_id, $plugin_definition, ConfigFactoryInterface $config_factory) { |
||||||
|
parent::__construct($configuration, $plugin_id, $plugin_definition); |
||||||
|
|
||||||
|
$this->configFactory = $config_factory; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* {@inheritdoc} |
||||||
|
*/ |
||||||
|
public function getDescription() { |
||||||
|
return $this->t('Render citation by citeproc-php library'); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* {@inheritdoc} |
||||||
|
*/ |
||||||
|
public function render($data, $csl, $lang) { |
||||||
|
$cite_proc = new CiteProc($csl, $lang); |
||||||
|
$mode = !empty($data['mode']) ? $data['mode'] : NULL; |
||||||
|
|
||||||
|
if (!$data instanceof \stdClass) { |
||||||
|
$data = json_decode(json_encode($data)); |
||||||
|
} |
||||||
|
|
||||||
|
return $cite_proc->render($data, $mode); |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,401 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace Drupal\bibcite_footnotes\Plugin\Filter; |
||||||
|
|
||||||
|
use Drupal\Component\Utility\Xss; |
||||||
|
use Drupal\Core\Form\FormStateInterface; |
||||||
|
use Drupal\filter\FilterProcessResult; |
||||||
|
use Drupal\filter\Plugin\FilterBase; |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* Reference Footnotes filter. |
||||||
|
* |
||||||
|
* @Filter( |
||||||
|
* id = "filter_reference_footnotes", |
||||||
|
* module = "bibcite_footnotes", |
||||||
|
* title = @Translation("Reference Footnotes filter"), |
||||||
|
* description = @Translation("You can insert footnotes directly into texts."), |
||||||
|
* type = \Drupal\filter\Plugin\FilterInterface::TYPE_TRANSFORM_IRREVERSIBLE, |
||||||
|
* cache = FALSE, |
||||||
|
* settings = { |
||||||
|
* "footnotes_footnotefootnote_linkcollapse" = FALSE, |
||||||
|
* "footnotes_ibid" = FALSE, |
||||||
|
* "notes_section_label" = "Notes", |
||||||
|
* }, |
||||||
|
* weight = 0 |
||||||
|
* ) |
||||||
|
*/ |
||||||
|
class ReferenceFootnotesFilter extends FilterBase { |
||||||
|
|
||||||
|
/** |
||||||
|
* Object with configuration for reference footnotes. |
||||||
|
* |
||||||
|
* @var object |
||||||
|
*/ |
||||||
|
protected $config; |
||||||
|
|
||||||
|
/** |
||||||
|
* Object with configuration for reference footnotes, where we need editable.. |
||||||
|
* |
||||||
|
* @var object |
||||||
|
*/ |
||||||
|
protected $configEditable; |
||||||
|
|
||||||
|
/** |
||||||
|
* {@inheritdoc} |
||||||
|
*/ |
||||||
|
public function __construct(array $configuration, $plugin_id, array $plugin_definition) { |
||||||
|
parent::__construct($configuration, $plugin_id, $plugin_definition); |
||||||
|
|
||||||
|
$this->renderer = \Drupal::service('renderer'); |
||||||
|
$this->config = \Drupal::config('reference_footnotes.settings'); |
||||||
|
$this->configEditable = \Drupal::configFactory() |
||||||
|
->getEditable('reference_footnotes.settings'); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Create the settings form for the filter. |
||||||
|
* |
||||||
|
* @param array $form |
||||||
|
* A minimally prepopulated form array. |
||||||
|
* @param FormStateInterface $form_state |
||||||
|
* The state of the (entire) configuration form. |
||||||
|
* |
||||||
|
* @return array |
||||||
|
* The $form array with additional form elements for the settings of |
||||||
|
* this filter. The submitted form values should match $this->settings. |
||||||
|
*/ |
||||||
|
public function settingsForm(array $form, FormStateInterface $form_state) { |
||||||
|
$settings['footnotes_collapse'] = [ |
||||||
|
'#type' => 'checkbox', |
||||||
|
'#title' => $this->t('Collapse reference footnotes with identical content'), |
||||||
|
'#default_value' => $this->settings['footnotes_collapse'], |
||||||
|
'#description' => t('If two reference footnotes have the exact same content, they will be collapsed into one as if using the same value="" attribute.'), |
||||||
|
]; |
||||||
|
$settings['footnotes_ibid'] = [ |
||||||
|
'#type' => 'checkbox', |
||||||
|
'#title' => $this->t('Display subsequent instances of multiple references with \'Ibid.\''), |
||||||
|
'#default_value' => $this->settings['footnotes_ibid'], |
||||||
|
]; |
||||||
|
$settings['notes_section_label'] = [ |
||||||
|
'#type' => 'textfield', |
||||||
|
'#title' => t('Notes section heading label'), |
||||||
|
'#default_value' => $this->settings['notes_section_label'], |
||||||
|
]; |
||||||
|
$settings['reference_dont_show_backlink_text'] = [ |
||||||
|
'#type' => 'checkbox', |
||||||
|
'#title' => $this->t("Don't show note 'value' text in reference list."), |
||||||
|
'#description' => $this->t("Suitable for MLA-style citations, like (Smith, 33-22)"), |
||||||
|
'#default_value' => $this->settings['reference_dont_show_backlink_text'], |
||||||
|
]; |
||||||
|
$settings['works_cited_sort_by'] = [ |
||||||
|
'#type' => 'select', |
||||||
|
'#title' => $this->t("Sort Workd Cited list by"), |
||||||
|
'#options' => [ |
||||||
|
'weight' => $this->t("Manually"), |
||||||
|
'alphabetical' => $this->t("Alphabetically"), |
||||||
|
], |
||||||
|
'#default_value' => $this->settings['works_cited_sort_by'], |
||||||
|
]; |
||||||
|
return $settings; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Helper function called from preg_replace_callback() above. |
||||||
|
* |
||||||
|
* Uses static vars to temporarily store footnotes found. |
||||||
|
* This is not threadsafe, but PHP isn't. |
||||||
|
* |
||||||
|
* @param array $matches |
||||||
|
* Elements from array: |
||||||
|
* - 0: complete matched string. |
||||||
|
* - 1: tag name. |
||||||
|
* - 2: tag attributes. |
||||||
|
* - 3: tag content. |
||||||
|
* @param string $op |
||||||
|
* Operation. |
||||||
|
* |
||||||
|
* @return string |
||||||
|
* Return the string processed by geshi library. |
||||||
|
*/ |
||||||
|
protected function replaceCallback($matches, $op = '') { |
||||||
|
static $opt_collapse = 0; |
||||||
|
static $n = 0; |
||||||
|
static $store_matches = []; |
||||||
|
static $used_values = []; |
||||||
|
$str = ''; |
||||||
|
|
||||||
|
if ($op == 'prepare') { |
||||||
|
// In the 'prepare' case, the first argument contains the options to use. |
||||||
|
// The name 'matches' is incorrect, we just use the variable anyway. |
||||||
|
$opt_collapse = isset($matches['footnotes_collapse']) && $matches['footnotes_collapse']; |
||||||
|
return 0; |
||||||
|
} |
||||||
|
|
||||||
|
if ($op == 'output footer') { |
||||||
|
|
||||||
|
|
||||||
|
if (count($store_matches) > 0) { |
||||||
|
// Separate out endontes and reference notes. |
||||||
|
|
||||||
|
if ($this->settings['footnotes_ibid']) { |
||||||
|
$this->ibidemify($references); |
||||||
|
} |
||||||
|
// Only if there are stored fn matches, pass the array of fns to be |
||||||
|
// themed as a list |
||||||
|
$markup = [ |
||||||
|
'#theme' => 'bibcite_footnote_list', |
||||||
|
'#notes' => $store_matches, |
||||||
|
'#config' => $this->settings, |
||||||
|
]; |
||||||
|
$str = \Drupal::service('renderer')->render($markup, FALSE); |
||||||
|
} |
||||||
|
// Reset the static variables so they can be used again next time. |
||||||
|
$n = 0; |
||||||
|
$store_matches = []; |
||||||
|
$used_values = []; |
||||||
|
|
||||||
|
return $str; |
||||||
|
} |
||||||
|
|
||||||
|
// Default op: act as called by preg_replace_callback() |
||||||
|
// Random string used to ensure footnote id's are unique, even |
||||||
|
// when contents of multiple nodes reside on same page. |
||||||
|
// (fixes http://drupal.org/node/194558). |
||||||
|
$randstr = $this->randstr(); |
||||||
|
|
||||||
|
$value = $this->extractAttribute($matches, 'value'); |
||||||
|
$page = $this->extractAttribute($matches, 'page'); |
||||||
|
$reference = $this->extractAttribute($matches, 'reference'); |
||||||
|
|
||||||
|
if ($value) { |
||||||
|
// A value label was found. If it is numeric, record it in $n so further |
||||||
|
// notes can increment from there. |
||||||
|
// After adding support for multiple references to same footnote in the |
||||||
|
// body (http://drupal.org/node/636808) also must check that $n is |
||||||
|
// monotonously increasing. |
||||||
|
if (is_numeric($value) && $n < $value) { |
||||||
|
$n = $value; |
||||||
|
} |
||||||
|
} |
||||||
|
elseif ($opt_collapse and $value_existing = $this->findFootnote($matches[2], $reference, $store_matches)) { |
||||||
|
// An identical footnote already exists. Set value to the previously |
||||||
|
// existing value. |
||||||
|
$value = $value_existing; |
||||||
|
} |
||||||
|
else { |
||||||
|
// No value label, either a plain <fn> or unparsable attributes. Increment |
||||||
|
// the footnote counter, set label equal to it. |
||||||
|
$n++; |
||||||
|
$value = $n; |
||||||
|
} |
||||||
|
|
||||||
|
// Remove illegal characters from $value so it can be used as an HTML id |
||||||
|
// attribute. |
||||||
|
$value_id = preg_replace('|[^\w\-]|', '', $value); |
||||||
|
|
||||||
|
|
||||||
|
// Create a sanitized version of $text that is suitable for using as HTML |
||||||
|
// attribute value. (In particular, as the title attribute to the footnote |
||||||
|
// link). |
||||||
|
$allowed_tags = []; |
||||||
|
$text_clean = Xss::filter($matches['2'], $allowed_tags); |
||||||
|
// HTML attribute cannot contain quotes. |
||||||
|
$text_clean = str_replace('"', """, $text_clean); |
||||||
|
// Remove newlines. Browsers don't support them anyway and they'll confuse |
||||||
|
// line break converter in filter.module. |
||||||
|
$text_clean = str_replace("\n", " ", $text_clean); |
||||||
|
$text_clean = str_replace("\r", "", $text_clean); |
||||||
|
|
||||||
|
// Create a footnote item as an array. |
||||||
|
$fn = [ |
||||||
|
'value' => $value, |
||||||
|
'text' => $matches[2], |
||||||
|
'text_clean' => $text_clean, |
||||||
|
'page' => $page, |
||||||
|
'reference' => $reference, |
||||||
|
'fn_id' => 'footnote' . $value_id . '_' . $randstr, |
||||||
|
'ref_id' => 'footnoteref' . $value_id . '_' . $randstr, |
||||||
|
]; |
||||||
|
|
||||||
|
// We now allow to repeat the footnote value label, in which case the link |
||||||
|
// to the previously existing footnote is returned. Content of the current |
||||||
|
// footnote is ignored. See http://drupal.org/node/636808 . |
||||||
|
if (!in_array($value, $used_values)) { |
||||||
|
// This is the normal case, add the footnote to $store_matches. |
||||||
|
// Store the footnote item. |
||||||
|
array_push($store_matches, $fn); |
||||||
|
array_push($used_values, $value); |
||||||
|
} |
||||||
|
else { |
||||||
|
// A footnote with the same label already exists. |
||||||
|
// Use the text and id from the first footnote with this value. |
||||||
|
// Any text in this footnote is discarded. |
||||||
|
$i = array_search($value, $used_values); |
||||||
|
$fn['text'] = $store_matches[$i]['text']; |
||||||
|
$fn['text_clean'] = $store_matches[$i]['text_clean']; |
||||||
|
$fn['fn_id'] = $store_matches[$i]['fn_id']; |
||||||
|
// Push the new ref_id into the first occurrence of this footnote label |
||||||
|
// The stored footnote thus holds a list of ref_id's rather than just one |
||||||
|
// id. |
||||||
|
$ref_array = is_array($store_matches[$i]['ref_id']) ? $store_matches[$i]['ref_id'] : [$store_matches[$i]['ref_id']]; |
||||||
|
array_push($ref_array, $fn['ref_id']); |
||||||
|
$store_matches[$i]['ref_id'] = $ref_array; |
||||||
|
} |
||||||
|
|
||||||
|
// Return the item themed into a footnote link. |
||||||
|
// Drupal 7 requires we use "render element" which just introduces a wrapper |
||||||
|
// around the old array. |
||||||
|
$fn = [ |
||||||
|
'#theme' => 'bibcite_footnote_link', |
||||||
|
'fn' => $fn, |
||||||
|
]; |
||||||
|
|
||||||
|
|
||||||
|
$result = \Drupal::service('renderer')->render($fn, FALSE); |
||||||
|
|
||||||
|
return $result; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* @inheritdoc |
||||||
|
*/ |
||||||
|
private function findFootnote($text, $reference, &$store_matches) { |
||||||
|
if (!empty($store_matches)) { |
||||||
|
foreach ($store_matches as &$fn) { |
||||||
|
if ($fn['text'] == $text && $fn['reference'] == $reference) { |
||||||
|
return $fn['value']; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
return FALSE; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* @param $matches |
||||||
|
* @param $value_match |
||||||
|
* |
||||||
|
* @return string |
||||||
|
*/ |
||||||
|
protected function extractAttribute($matches, $attribute): string { |
||||||
|
$value = ''; |
||||||
|
// Did the pattern match anything in the <fn> tag? |
||||||
|
if ($matches[1]) { |
||||||
|
// See if value attribute can parsed, either well-formed in quotes eg |
||||||
|
// <fn value="3">. |
||||||
|
if (preg_match('|' . $attribute . '=["\'](.*?)["\']|', $matches[1], $value_match)) { |
||||||
|
$value = $value_match[1]; |
||||||
|
// Or without quotes eg <fn value=8>. |
||||||
|
} |
||||||
|
elseif (preg_match('|' . $attribute . '=(\S*)|', $matches[1], $value_match)) { |
||||||
|
$value = $value_match[1]; |
||||||
|
} |
||||||
|
} |
||||||
|
return $value; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Determine references that are the same as one above it |
||||||
|
* to be replaced with the string 'Ibid'. |
||||||
|
* |
||||||
|
* @param array $footnotes |
||||||
|
*/ |
||||||
|
protected function ibidemify(&$footnotes) { |
||||||
|
$prev_reference_id = FALSE; |
||||||
|
foreach ($footnotes as $index => $fn) { |
||||||
|
if ($prev_reference_id) { |
||||||
|
if ($fn['reference'] == $prev_reference_id) { |
||||||
|
$footnotes[$index]['ibid'] = TRUE; |
||||||
|
continue; |
||||||
|
} |
||||||
|
} |
||||||
|
$prev_reference_id = $fn['reference']; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* {@inheritdoc} |
||||||
|
*/ |
||||||
|
public function process($text, $langcode) { |
||||||
|
// Supporting both [fn] and <fn> now. Thanks to fletchgqc |
||||||
|
// http://drupal.org/node/268026. |
||||||
|
// Convert all square brackets to angle brackets. This way all further code |
||||||
|
// just manipulates angle brackets. (Angle brackets are preferred here for |
||||||
|
// the simple reason that square brackets are more tedious to use in |
||||||
|
// regexps). |
||||||
|
if (is_array($text)) { |
||||||
|
implode($text); |
||||||
|
} |
||||||
|
$text = preg_replace('|\[fn([^\]]*)\]|', '<fn$1>', $text); |
||||||
|
$text = preg_replace('|\[/fn\]|', '</fn>', $text); |
||||||
|
$text = preg_replace('|\[footnotes([^\]]*)\]|', '<footnotes$1>', $text); |
||||||
|
|
||||||
|
// Check that there are an even number of open and closing tags. |
||||||
|
// If there is one closing tag missing, append this to the end. |
||||||
|
// If there is more disparity, throw a warning and continue. |
||||||
|
// A closing tag may sometimes be missing when we are processing a teaser |
||||||
|
// and it has been cut in the middle of the footnote. |
||||||
|
// See http://drupal.org/node/253326 |
||||||
|
$foo = []; |
||||||
|
$open_tags = preg_match_all("|<fn([^>]*)>|", $text, $foo); |
||||||
|
$close_tags = preg_match_all("|</fn>|", $text, $foo); |
||||||
|
|
||||||
|
if ($open_tags == $close_tags + 1) { |
||||||
|
$text = $text . '</fn>'; |
||||||
|
} |
||||||
|
elseif ($open_tags > $close_tags + 1) { |
||||||
|
trigger_error($this->t("You have unclosed fn tags. This is invalid and will |
||||||
|
produce unpredictable results.")); |
||||||
|
} |
||||||
|
|
||||||
|
// Before doing the replacement, the callback function needs to know which |
||||||
|
// options to use. |
||||||
|
$this->replaceCallback($this->settings, 'prepare'); |
||||||
|
|
||||||
|
$pattern = '|<fn([^>]*)>(.*?)</fn>|s'; |
||||||
|
$text = preg_replace_callback($pattern, [ |
||||||
|
$this, |
||||||
|
'replaceCallback', |
||||||
|
], $text); |
||||||
|
|
||||||
|
// Replace tag <footnotes> with the list of footnotes. |
||||||
|
// If tag is not present, by default add the footnotes at the end. |
||||||
|
// Thanks to acp on drupal.org for this idea. see |
||||||
|
// http://drupal.org/node/87226. |
||||||
|
$footer = $this->replaceCallback(NULL, 'output footer'); |
||||||
|
$pattern = '|(<footnotes([^\]]*)>)|'; |
||||||
|
if (preg_match($pattern, $text) > 0) { |
||||||
|
$text = preg_replace($pattern, $footer, $text, 1); |
||||||
|
} |
||||||
|
elseif (!empty($footer)) { |
||||||
|
$text .= "\n\n" . $footer; |
||||||
|
} |
||||||
|
$result = new FilterProcessResult($text); |
||||||
|
$result->setAttachments([ |
||||||
|
'library' => [ |
||||||
|
'footnotes/footnotes', |
||||||
|
], |
||||||
|
]); |
||||||
|
return $result; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* Helper function to return a random text string. |
||||||
|
* |
||||||
|
* @return string |
||||||
|
* Random (lowercase) alphanumeric string. |
||||||
|
*/ |
||||||
|
public function randstr() { |
||||||
|
$chars = "abcdefghijklmnopqrstuwxyz1234567890"; |
||||||
|
$str = ""; |
||||||
|
|
||||||
|
// Seeding with srand() not necessary in modern PHP versions. |
||||||
|
for ($i = 0; $i < 7; $i++) { |
||||||
|
$n = rand(0, strlen($chars) - 1); |
||||||
|
$str .= substr($chars, $n, 1); |
||||||
|
} |
||||||
|
return $str; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,16 @@ |
|||||||
|
{# |
||||||
|
/** |
||||||
|
* @file footnote-link.html.twig |
||||||
|
* Default theme implementation to present an inline reference footnote link. |
||||||
|
* |
||||||
|
* Available variables: |
||||||
|
* - fn: Components of the footnote |
||||||
|
* - link: Rendered link. |
||||||
|
* - attributes: HTML attributes for the container element. |
||||||
|
* |
||||||
|
* @see template_preprocess_footnote_link(). |
||||||
|
* |
||||||
|
* @ingroup themeable |
||||||
|
*/ |
||||||
|
#} |
||||||
|
{{ fn }} |
Loading…
Reference in new issue