X-Git-Url: https://git.nikiroo.be/?a=blobdiff_plain;ds=sidebyside;f=src%2Fbe%2Fnikiroo%2Ffanfix%2Fsupported%2FBasicSupportPara.java;h=e550d82ee0257ffb84bd8a9aee0eddf044d3c55e;hb=1dbed6237611f74292af13f20f9d80c446a60020;hp=d3beea53b47c39b251c5b31647397f54628ac54f;hpb=68328e172319fe97d76805d60f560376af2fcb5b;p=fanfix.git diff --git a/src/be/nikiroo/fanfix/supported/BasicSupportPara.java b/src/be/nikiroo/fanfix/supported/BasicSupportPara.java index d3beea5..e550d82 100644 --- a/src/be/nikiroo/fanfix/supported/BasicSupportPara.java +++ b/src/be/nikiroo/fanfix/supported/BasicSupportPara.java @@ -20,30 +20,46 @@ import be.nikiroo.utils.StringUtils; /** * Helper class for {@link BasicSupport}, mostly dedicated to {@link Paragraph} - * and text formating for the {@link BasicSupport} class itself (not its - * children). + * and text formating for the {@link BasicSupport} class. * * @author niki */ -class BasicSupportPara { +public class BasicSupportPara { // quote chars - private static char openQuote = Instance.getTrans().getCharacter( - StringId.OPEN_SINGLE_QUOTE); - private static char closeQuote = Instance.getTrans().getCharacter( - StringId.CLOSE_SINGLE_QUOTE); - private static char openDoubleQuote = Instance.getTrans().getCharacter( - StringId.OPEN_DOUBLE_QUOTE); - private static char closeDoubleQuote = Instance.getTrans().getCharacter( - StringId.CLOSE_DOUBLE_QUOTE); - + private static char openQuote = Instance.getInstance().getTrans().getCharacter(StringId.OPEN_SINGLE_QUOTE); + private static char closeQuote = Instance.getInstance().getTrans().getCharacter(StringId.CLOSE_SINGLE_QUOTE); + private static char openDoubleQuote = Instance.getInstance().getTrans().getCharacter(StringId.OPEN_DOUBLE_QUOTE); + private static char closeDoubleQuote = Instance.getInstance().getTrans().getCharacter(StringId.CLOSE_DOUBLE_QUOTE); + + // used by this class: + BasicSupportHelper bsHelper; + BasicSupportImages bsImages; + + /** + * Create a new {@link BasicSupportPara}. + *
+ * Note that you need an instance of both {@link BasicSupportHelper} and
+ * {@link BasicSupportImages} for it to work.
+ *
+ * @param bsHelper
+ * the required {@link BasicSupportHelper}
+ * @param bsImages
+ * the required {@link BasicSupportImages}
+ */
+ public BasicSupportPara(BasicSupportHelper bsHelper, BasicSupportImages bsImages) {
+ this.bsHelper = bsHelper;
+ this.bsImages = bsImages;
+ }
+
/**
* Create a {@link Chapter} object from the given information, formatting
* the content as it should be.
*
* @param support
- * the linked {@link BasicSupport}
+ * the linked {@link BasicSupport} (can be NULL)
* @param source
- * the source of the story
+ * the source of the story (for image lookup in the same path if
+ * the source is a file, can be NULL)
* @param number
* the chapter number
* @param name
@@ -55,23 +71,21 @@ class BasicSupportPara {
* @param html
* TRUE if the input content is in HTML mode
*
- * @return the {@link Chapter}
+ * @return the {@link Chapter}, never NULL
*
* @throws IOException
* in case of I/O error
*/
- public static Chapter makeChapter(BasicSupport support, URL source,
+ public Chapter makeChapter(BasicSupport support, URL source,
int number, String name, String content, boolean html, Progress pg)
throws IOException {
// Chapter name: process it correctly, then remove the possible
// redundant "Chapter x: " in front of it, or "-" (as in
// "Chapter 5: - Fun!" after the ": " was automatically added)
- String chapterName = BasicSupportPara.processPara(name, false)
+ String chapterName = processPara(name, false)
.getContent().trim();
- for (String lang : Instance.getConfig().getString(Config.CHAPTER)
- .split(",")) {
- String chapterWord = Instance.getConfig().getStringX(
- Config.CHAPTER, lang);
+ for (String lang : Instance.getInstance().getConfig().getList(Config.CONF_CHAPTER)) {
+ String chapterWord = Instance.getInstance().getConfig().getStringX(Config.CONF_CHAPTER, lang);
if (chapterName.startsWith(chapterWord)) {
chapterName = chapterName.substring(chapterWord.length())
.trim();
@@ -117,7 +131,7 @@ class BasicSupportPara {
*
* @return the correctly (or so we hope) quotified paragraphs
*/
- private static List